Index: Dev/trunk/classes/Toolbox.php
===================================================================
--- Dev/trunk/classes/Toolbox.php	(revision 184)
+++ Dev/trunk/classes/Toolbox.php	(revision 185)
@@ -16,28 +16,14 @@
 
         <br />
-        
+
         <div id="toolbox" class="largeFrame">
             <div class="largeTitle">Toolbox</div>
             <div class="content">
                 <p style="float: left; clear:both; margin-bottom: 1em;">Add new:</p>
-                <div class="bigButton vert" onClick="SubmitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon" /><p>Survey</p></div>
-                <div class="bigButton vert" onClick="SubmitToolbox('Application');"><img src="images/icons/application.png" class="buttonIcon" /><p>Application</p></div>
-                <div class="bigButton vert" onClick="SubmitToolbox('Dashboard');"><img src="images/icons/dashboard.png" class="buttonIcon" /><p>Dashboard</p></div>
+                <div class="bigButton toolbox" onClick="submitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon" /><p>Survey</p></div>
+                <div class="bigButton toolbox" onClick="submitToolbox('Application');"><img src="images/icons/application.png" class="buttonIcon" /><p>Application</p></div>
+                <div class="bigButton toolbox" onClick="submitToolbox('Dashboard');"><img src="images/icons/dashboard.png" class="buttonIcon" /><p>Dashboard</p></div>
             </div>
         </div>
-        
-        
-        <!--
-        <form name="toolbox" action="pipelineEditor.php" method="POST">
-            <fieldset id="toolbox">
-                <div class="fieldsetTitle">Toolbox</div>
-                <p>Add new: </p>
-                <div class="creationButton" onClick="SubmitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>
-                <div class="creationButton" onClick="SubmitToolbox('Application');"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div>
-                <div class="creationButton" onClick="SubmitToolbox('Dashboard');"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>
-            </fieldset>
-        </form>
-        
-        -->
         <?php
     }
Index: Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- Dev/trunk/classes/pipelineSequencer.php	(revision 184)
+++ Dev/trunk/classes/pipelineSequencer.php	(revision 185)
@@ -81,5 +81,5 @@
         <script type="text/javascript">
             $(document).ready(function() {
-                loadSequencer();      // true means it is the first refresh of the page.
+                loadSequencer();
             });
         </script>
@@ -87,61 +87,22 @@
     }
 
-    public function LoadSession($currentSession) {   // Initialize variables on page load.
-        if (!isset($currentSession)) {
+    public function LoadSession() {   // Initialize variables on page load.
+        // Redirect if no session is set
+        if (!isset($_SESSION['currentSession'])) {
             redirect("selectSession.php");
         }
-        if (isset($_SESSION['updateNeeded'])) {    // user has performed an operation that flags session to be reloaded from DB, or is first load of page for that session
-            $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession));
-
-            if (count($sessionResults) > 0) {
-                $_SESSION['localSessionCopy'] = $sessionResults[0];
-                unset($_SESSION['updateNeeded']);
-            } else {
-                die("No session with that UID found!");
-            }
+        // Store the current session in internal variable
+        $results = $this->dbi->get("Session", array("uid"=> $_SESSION['currentSession']));
+        if (!empty($results)) {
+            (is_array($results)) ? $this->loadedSession = $results[0] : $this->loadedSession = $results;
         }
-
-        if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
-
-            $this->loadedSession = $_SESSION['localSessionCopy'];
-            unset($_SESSION['updateNeeded']);
+        else {
+            // Throw error and quit if no results found
+            die("No session with that UID found!");
         }
     }
 
     public function HandlePostData() {
-        if (isset($_POST['editSelected'])) {
-            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
-                redirect("editredirect.php");
-            }
-        }
-
-        if (isset($_POST['moveSelectedLeft'])) {
-            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
-                $this->MoveStep($_POST['selectedStep'], -1);
-            }
-        }
-
-        if (isset($_POST['moveSelectedRight'])) {
-            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
-                $this->MoveStep($_POST['selectedStep'], 1);
-            }
-        }
-
-        if (isset($_POST['objectToCreate']) && !empty($_POST['objectToCreate'])) {
-            switch (strtolower($_POST['objectToCreate'])) {
-                case "survey":
-                    redirect("createsurvey.php");
-                    break;
-                case "application":
-                    redirect("createapplication.php");
-                    break;
-                case "dashboard":
-                    redirect("createdashboard.php");
-                    break;
-                default:
-                    // Er is iets fout gegaan, want er is geen valid type meegegeven!
-                    break;
-            }
-        }
+                
     }
 
Index: Dev/trunk/classes/surveyEditorWidget.php
===================================================================
--- Dev/trunk/classes/surveyEditorWidget.php	(revision 184)
+++ Dev/trunk/classes/surveyEditorWidget.php	(revision 185)
@@ -12,60 +12,63 @@
 class surveyEditorWidget {
 
-    private $loadedSession;
+    private $loadedSurvey;
+    private $dbi;
 
     public function __construct() {
         // Set basic variables
         // Should probably include a default empty survey for the sake of safety
+        $dbi = new DatabaseInterface();
     }
 
     public function handlePost() {
         // Get POSTed data and store variables to class instance properties
-        // Most important: loadedSession!
-
-        //var_dump($_POST);
-
         $dbi = new DatabaseInterface();
         if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) {
             $surveyResults = $dbi->get("Survey", array("uid" => $_POST['objectUid']));
-            if (count($surveyResults) > 0) {
-                $this->loadedSurvey = $surveyResults[0];
+            if (!empty($surveyResults)) {
+                (is_array($surveyResults)) ? $this->loadedSurvey = $surveyResults[0] : $this->loadedSurvey = $surveyResults;
             } else {
-                var_dump("No surveys found!");
+                die("No surveys found!");
             }
         } else {
-            var_dump("Incorrect or null uid passed!");
+            die("Incorrect or null uid passed!");
         }
     }
 
     public function init() {
+        $questionString = "";
+        foreach ($this->loadedSurvey->questions as $question) {
+            $questionString .= $question->uid . ",";
+        }
         // echo the HTML markup to display the editor on the screen
         ?>
 
         <div id="surveyEditor" class="largeFrame">
-            <div class="largeTitle">
-                Survey name
+            <div class="largeTitle" id="surveyTitle">
+                <?php echo $this->loadedSurvey->title; ?>
             </div>
-            <div id="surveyEditorContent" class="innerLargeFrame">
+            <div id="seqContent" class="innerLargeFrame">
+                <div id="seqContentWrapper">
 
-                <!--
-                <div id="questionUID" class="smallFrame">
-                    <div class="smallTitle"><div class="listNumber">1</div>#QUESTION-IDENT-NO</div>
-                    <div class="content">
-                        <p class="questionBody">
-                            This is the question body text. This is what the user will read when he is answering the survey.This is the question body text. This is what the user will read when he is answering the survey.This is the question body text. This is what the user will read when he is answering the survey.
-                        </p>
-                        <div class="questionParamsView">
-                            PARAMETERS GO HERE, probably in one line (Only answer type and identifier?) Tags?
-                        </div>
-                    </div>
-                    <div id="questionDisplayControls" class="controls">
-                        <input type="button" value="Edit" onClick="javascript:alert('editing not yet supported');" class =" smallButton"/>
-                        <input type="button" value="Remove" onClick="javascript:alert('removing not yet supported');" class =" smallButton"/>
-                    </div>
                 </div>
-                -->
-
+            </div>
+            <div id="surveyEditorVertControls" class="vertControls">
+                <div class="segment">
+                    <label>Move</label>
+                    <input type="button" id="vertControls_MoveUp" class="bigButton vertical" value="Ë" />
+                    <input type="button" id="vertControls_MoveDown" class="bigButton vertical" value="Ë
+" />
+                </div>
+                <input type="button" id="vertControls_Add" class="bigButton vertical" value="+" onClick="addQuestion_Click();" />
             </div>
             <div id="surveyEditorControls" class="controls">
+                <div id="pageControls">
+                    <input type="button" value="<<" id="pageControls_first" onClick="" />
+                    <input type="button" value="<" id="pageControls_previous" onClick="" />
+                    Page <input type="text" value="1" id="pageControls_current" onChange="" class="smallTextField" /> of 5
+                    <input type="button" value=">" id="pageControls_next" onClick="" />
+                    <input type="button" value=">>" id="pageControls_last" onClick="" />
+                </div>
+
                 <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" />
                 <input type="button" value="Save survey" onClick="javascript:alert('save not yet supported');" class="smallButton" />
@@ -75,10 +78,10 @@
 
 
-        <form name="hiddenFields">
-            <input type="hidden" id="surveyUid" value="<?php echo $this->loadedSurvey->uid; ?>" />
-            <input type="hidden" id="questionUids" value="<?php echo $this->loadedSurvey->questions; ?>" />
-            <input type="hidden" id="surveyTitle" value="<?php echo $this->loadedSurvey->title; ?>" />
-            <input type="hidden" id="numQuestions" value="<?php echo count($this->loadedSurvey->questions); ?>" />
-            <input type="hidden" id="surveyDescription" value="<?php echo $this->loadedSurvey->description; ?>" />
+        <form id="hiddenInputs">
+            <input type="hidden" id="surveyUidField" value="<?php echo $this->loadedSurvey->uid; ?>" />
+            <input type="hidden" id="questionUidsField" value="<?php echo $questionString ?>" />
+            <input type="hidden" id="surveyTitleField" value="<?php echo $this->loadedSurvey->title; ?>" />
+            <input type="hidden" id="numQuestionsField" value="<?php echo count($this->loadedSurvey->questions); ?>" />
+            <input type="hidden" id="surveyDescriptionField" value="<?php echo $this->loadedSurvey->description; ?>" />
         </form>
 
@@ -90,9 +93,10 @@
         // output the javascript tags and needed functions in the head of the page
         ?>
-        <script type="text/javascript" src="js/surveyEditorScripts.js"></script>
+        <script type="text/javascript" src="js/sequencerScripts.js"></script>
+        <script type="text/javascript" src="js/generalscripts.js"></script>
         <script type="text/javascript" src="js/jquery.js"></script>
         <script type="text/javascript">
             $(document).ready(function() {
-                loadSurvey();
+                loadSequencer();
             });
         </script>
Index: Dev/trunk/createObject.php
===================================================================
--- Dev/trunk/createObject.php	(revision 184)
+++ Dev/trunk/createObject.php	(revision 185)
@@ -6,20 +6,17 @@
     if (!empty($_POST['objectToCreate'])) {
         $otc = $_POST['objectToCreate'];
-    }
-    else {
+    } else {
         //die ("Invalid arguments passed!");
     }
-}
-else {
+} else {
     //die ("No arguments passed!");
 }
 
 $dbi = new DatabaseInterface();
-$creator_results = $dbi->get("User", array("name"=>$_SESSION['username']));
+$creator_results = $dbi->get("User", array("name" => $_SESSION['username']));
 if (count($creator_results) > 0) {
     $creator = $creator_results[0];
-}
-else {
-    //die ("Invalid creator, make sur0e you are logged in!");
+} else {
+    //die ("Invalid creator, make sure you are logged in!");
 }
 
@@ -39,4 +36,9 @@
         //TODO
         break;
+    case "question":
+        $newQuestion = new Question(null, "new Question", "int", "Default description", "Standard category", array());
+        $dbi->set($newQuestion);
+        $uid = $newQuestion->uid;
+        break;
     default:
         //die ("Variable \$otc: $otc does not match a compatible object type!");
@@ -45,4 +47,3 @@
 
 echo $uid;
-
 ?>
Index: Dev/trunk/css/visualeditors.css
===================================================================
--- Dev/trunk/css/visualeditors.css	(revision 184)
+++ Dev/trunk/css/visualeditors.css	(revision 185)
@@ -141,4 +141,8 @@
 }
 
+.smallFrame.selected .smallTitle {
+    background-color: #FF0000;
+}
+
 .largeTitle {
     width: auto;
@@ -151,4 +155,5 @@
 
 .smallTitle {
+    background-color: transparent;
     width: auto;
     min-height: 1.5em;
@@ -170,19 +175,4 @@
     float: right;
     min-height: 2.5em;
-}
-
-.questionBody {
-    float: left;
-    clear: left;
-    margin: 1em 0;
-    font-style: italic;
-}
-
-.questionParamsView {
-    float: left;
-    clear: left;
-    border: 1px solid #555;
-    padding: 0.5em;
-    font-weight: bold;
 }
 
@@ -201,4 +191,24 @@
 }
 
+.bigButton.vertical {
+    width: 2em;
+    height: 2em;
+    font-size: 20px;
+    font-weight: bold;
+    color: #555;
+    float: left;
+    clear: both;
+    border: 1px solid #555;
+    border-radius: 0.25em;
+    -moz-border-radius: 0.25em;
+    background-color: transparent;
+    -webkit-user-select: none;
+    -khtml-user-select: none;
+    -moz-user-select: none;
+    -o-user-select: none;
+    user-select: none;
+    cursor: default;
+}
+
 .bigButton:hover {
     border-color: #1c94c4;
@@ -208,8 +218,4 @@
 .bigButton .buttonIcon {
 
-}
-
-.bigButton.vert {
-    clear:both;
 }
 
@@ -254,5 +260,5 @@
 }
 
-#seqContentWrapper .divider {
+#seqContentWrapper .divider.horizontal {
     width: 10px;
     height: 50px;
@@ -313,4 +319,8 @@
 }
 
+.bigButton.toolbox {
+    clear: both;
+}
+
 #infoPanel {
     margin-top: 2em;
@@ -344,2 +354,62 @@
     background-color: #0000FF;
 }
+
+#seqContentWrapper .divider.vertical {
+    height: 1px;
+    width: 200px;
+    background-color: #FF00FF; /* VIES MAGENTA! */
+    margin: 1em auto;
+}
+
+.questionBody {
+    float: left;
+    clear: left;
+    margin: 1em 0;
+    font-style: italic;
+}
+
+.questionParamsView {
+    float: left;
+    clear: left;
+    border: 1px solid #555;
+    padding: 0.5em;
+    font-weight: bold;
+}
+
+#pageControls {
+    float: left;
+    margin: 5px 200px 0 0;
+}
+
+#pageControls .smallTextField {
+    width: 1.5em;
+}
+
+.vertControls {
+    text-align: center;
+    display:block;
+    float: left;
+    clear: right;
+    margin: 0 0 0 1em;
+}
+
+.vertControls .segment {
+    margin: 1.25em -1px 0.25em -1px;
+    border: 1px solid #555;
+    clear: both;
+    padding: 1px;
+    float: left;
+    border-radius: 5px;
+}
+
+.vertControls label {
+    width: 100%;
+    float: left;
+    clear: both;
+    font-size: 12px;
+    text-align: center;
+    margin: -1.25em 0 0;
+    color: #555;
+    font-weight: bold;
+}
+
Index: Dev/trunk/getInfo.php
===================================================================
--- Dev/trunk/getInfo.php	(revision 184)
+++ Dev/trunk/getInfo.php	(revision 185)
@@ -28,4 +28,9 @@
 } else
     return;
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// Note: the next part needs to be converted to JSON operation, so that the javascript can easily handle any style changes to the information retrieved. This implementation is just silly.
+// Basic idea: return a JSON array of property: value pairs, then let javascript loop through these properties and format them suitably. This is both more flexible and easier to adjust, as well as resulting in smaller packets.
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 switch ($type) {
Index: Dev/trunk/js/sequencerScripts.js
===================================================================
--- Dev/trunk/js/sequencerScripts.js	(revision 184)
+++ Dev/trunk/js/sequencerScripts.js	(revision 185)
@@ -2,119 +2,194 @@
  * You can change the type of sequencer by including a hidden input field with id "contentTypeField" in your document.
  * The initEditor() method will then adjust internal variables in the sequencer object to match that type of content.
+ * 
+ * Note: code makes heavy use of shorthand functions:
+ * ce(var) = document.createElement(var);
+ * ge(var) = document.getElementById(var);
+ * Defined in generalscripts.js
  */
 
 var sequencer = createVarArray();
 
-function SubmitToolbox(type) {
-    if (sequencer.state.updating == true) return;
-    sequencer.state.updating = true;
-    deselectStep();    
-    var c = "objectToCreate="+type;
-    var u = "createObject.php";
-        
-    newAjaxRequest(c, u, function(result) {
-        sequencer.session.pipeline.uids.push(removeNL(result.responseText));
-        sequencer.session.pipeline.types.push(type);
-        sequencer.session.pipeline.upToDate.push(false);
-        updateSequencer();
-    }, true);
-}
-
-function clickStep(uid) {
-    if (uid == sequencer.state.selectedStep.uid) {  // user deselected a currently selected step.
-        deselectStep();
-    }
-    else {
-        if (sequencer.state.selectedStep.uid != undefined && sequencer.state.selectedStep.uid != "") {
-            deselectStep();
-            selectStep(uid);
-        }
-        else {
-            selectStep(uid);
-        }        
-    }
-}
-
-function selectStep(uid) {
-    var element = document.getElementById(uid);
-    if (element) {
-        addClass(element, "selected");
-        var type = sequencer.session.pipeline.types[sequencer.session.pipeline.uids.indexOf(uid)];
-        ajaxInfoRequest(uid, document.getElementById("infoPanelContent"), type);
-        sequencer.state.selectedStep.uid = uid;
-        sequencer.state.selectedStep.index = null;  //Don't know how to do this yet.
-    }
-}
-
-function deleteStep() {
-    // check if a step is selected
-    if (sequencer.state.selectedStep.uid == null) {
-        return;
-    }
-    var uid = sequencer.state.selectedStep.uid;
-    // deselect the step to reset the info panel and selection code
-    deselectStep();
-    // splice the step's data from the pipeline
-    var index = sequencer.session.pipeline.uids.indexOf(uid);
-    if (index >= 0 && index < sequencer.session.pipeline.uids.length) {
-        sequencer.session.pipeline.uids.splice(index, 1);
-        sequencer.session.pipeline.types.splice(index, 1);
-        sequencer.session.pipeline.upToDate.splice(index, 1);
-        // Then delete the step visually
-        var element = document.getElementById(uid);
-        var divider;
-        if (!element.nextSibling) {
-            // the element is at the end of the pipeline
-            // therefore we remove the previous divider.
-            // Note: it could also be the only element left in the pipeline!
-            divider = (element.previousSibling) ? element.previousSibling : false;
-            if (divider != false) {
-                divider.parentNode.removeChild(divider);
-            }
-        }
-        else {
-            // the element is at any position except the last, therefore we remove the next divider
-            divider = (element.nextSibling) ? element.nextSibling : false;
-            if (divider != false) {
-                divider.parentNode.removeChild(divider);
-            }
-        }
-        
-        // Finally, remove the element itself.
-        element.parentNode.removeChild(element);
-        sequencer.state.numSteps--;
-        
-    }
-}
-
-function deselectStep() {
-    if (!sequencer.state.selectedStep.uid) return;
-    var element = document.getElementById(sequencer.state.selectedStep.uid);
-    removeClass(element, "selected");
-    sequencer.state.selectedStep.uid = null;
-    sequencer.state.selectedStep.index = null;
-    var infoPanel = document.getElementById("infoPanelContent");
-    while (infoPanel.firstChild) infoPanel.removeChild(infoPanel.firstChild);
-}
-
-function ajaxInfoRequest(uid, el, type) {
-    var c = "uid="+uid;
-    c += "&type="+type;
-    var u = "getInfo.php";
-    newAjaxRequest(c, u, function(result) {
-        el.innerHTML = result.responseText;
-    }, true);
-}
+// Basic functions, intialization, updating
+
+function createVarArray(){
+    // Function that returns creates the global variable object, the sequencer's variable storage.
+    
+    if (sequencer) delete window.sequencer;
+    return {   // GLOBAL VAR TO STORE SEQUENCER SETTINGS!
+        uid: "",                // The unique id of this sequencer (not DB related!). This will help to avoid global var conflicts. Assign this randomly! (STRING)
+        session: {              // Properties of the currently loaded session
+            title: "",              // Title or name (STRING)
+            uid: "",                // Database UID of the current session (STRING)
+            pipeline: {             // Pipeline
+                uids: [],               // Uids of objects in pipeline (STRING)
+                types: [],              // Types of objects in pipeline (STRING)
+                upToDate: []            // Whether or not object displays are up to date (BOOL)
+            }
+        },
+        survey: {               // Properties of the loaded survey, if applicable (either this or the session tree above is filled in!) [THIS IS NOT CURRENTLY USED AND I SHOULD DELIBERATE ON WHAT VARIABLES TO PUT IN THIS TREE TO MAKE A FUNCTIONAL EDITOR THAT ALSO MATCHES THE DB FORMAT!]
+            title: "",              // Title or the name of the survey (STRING)
+            uid: "",                // Uid of the survey (STRING)
+            description: "",        // Description of the survey (STRING)
+            questions: {            // Properties of the questions contained within this survey
+                uids: [],               // An array of uids of the questions, in the order that they appear in the survey (STRING)
+                upToDate: []            // Whether or not a certain question needs an update (BOOL)
+            }
+        },
+        state: {                // Operating state of the sequencer
+            editing: false,         // Whether or not one of the contained child objects is currently being edited or in edit mode. Which one can be determined from the selectedObject property. (BOOL)
+            updating: false,        // Whether or not new steps are currently being queried (to disable any further actions) (BOOL)
+            numSteps: 0,            // Number of objects currently drawn in the editor (not necessarily same as number of objects in pipeline/survey!) (INTEGER)
+            loaded: false,          // Whether or not the sequencer content has been updated for the first time (BOOL)
+            selectedObject: {       // Properties of the currently selected step
+                uid: "",                // UID of this step (STRING)
+                index: null             // The 'index' of this step in the current sequencer view (NOT the pipeline!) (INTEGER)
+            },
+            pages: {                // State regarding page division of content objects
+                total: null,            // The number of pages the content is divided across
+                currentPage: null       // The page that is currently displayed in the sequencer            
+            }
+        },
+        settings: {             // Various settings to determine the workings of the sequencer
+            content: {              // Properties related to the content view of the sequencer
+                contentType: null,      // Type of the loaded parent object (STRING)
+                width: null,            // Width of the viewing area (INTEGER)
+                height: null,           // Height of the viewing area (INTEGER)
+                maxObjects: null,       // The maximum number of content elements to be displayed at once time (INTEGER)
+                orientation: null,      // Whether the editor should be a vertical or horizontal editor (STRING)
+                pages: false            // Whether or not to divide content across pages
+            },
+            efficientUpdating: true // Whether or not to use selective querying of the database for new step objects. True will only refresh out-of-date steps, False will refresh the whole pipeline (BOOL)
+        }
+    };
+
+}
+
+function loadSequencer() {
+    // Reads hidden fields created by PHP, copies the values into the global var then deletes them.
+    
+    // Load hidden fields and set required properties in global object var.
+    try {
+        // settings fields first
+        initSequencer();
+        
+        switch (sequencer.settings.content.contentType.toLowerCase()) {
+            case "session":
+                // Content-related fields next
+                var fPipelineString = ge("pipelineStringField");
+                var fPipelineTypes = ge("pipelineTypeField");
+                var fSessionUid = ge("sessionField");
+                var fSessionTitle = ge("sessionTitleField");
+                sequencer.session.title = fSessionTitle.value;
+                sequencer.session.uid = fSessionUid.value;
+                sequencer.session.pipeline.uids = stringToArray(fPipelineString.value, ",");
+                sequencer.session.pipeline.types = stringToArray(fPipelineTypes.value, ",");
+                sequencer.session.pipeline.upToDate = new Array();
+        
+                for (var i = 0; i < sequencer.session.pipeline.uids.length; i++) {
+                    sequencer.session.pipeline.upToDate.push(true);
+                }
+                break;
+            case "survey":
+                var fSurveyUid = ge("surveyUidField");
+                var fQuestionUids = ge("questionUidsField");
+                var fSurveyTitle = ge("surveyTitleField");
+                var fnumQuestions = ge("numQuestionsField");
+                var fSurveyDescription = ge("surveyDescriptionField");
+                sequencer.survey.title = fSurveyTitle.value;
+                sequencer.survey.uid = fSurveyUid.value;
+                sequencer.survey.description = fSurveyDescription.value;
+                sequencer.survey.questions.uids = stringToArray(fQuestionUids.value, ",");
+                break;
+            default:
+                break;
+        }
+        
+        
+        sequencer.state.numSteps = 0;
+        sequencer.state.loaded = false;
+        sequencer.settings.efficientUpdating = true;
+    }
+    catch (e) {
+        // Alert developer of any errors while setting these variables
+        for (error in e) alert(error.message);
+    }
+    // Then remove the hidden fields from the HTML document
+    var hiddenInputs = ge("hiddenInputs");
+    hiddenInputs.parentNode.removeChild(hiddenInputs);
+    
+    // finally, run updateSequencer to refresh the visual display of the pipeline
+    updateSequencer();
+}
+
+function initSequencer() {
+    // Called from loadSequencer(). Sets sequencer.settings properties depending on content type and values passed by PHP in hidden fields (currently only one), then removes these fields.
+    // Example: stuff like editor orientation, width/height, content type, maxObjects contained, etc...
+    
+    // load settings fields first
+    var fContentType = ge("sContentTypeField");
+    var content = ge("seqContent");
+    //sequencer.settings.content.contentType = fContentType.value.toLowerCase();
+    sequencer.settings.content.contentType = fContentType.value;
+    //Then select settings from a few presets
+    
+    switch (sequencer.settings.content.contentType.toLowerCase()) {
+        case "session":
+            sequencer.settings.content.orientation = "horizontal";
+            sequencer.settings.content.width = 800;
+            sequencer.settings.content.height = 125;
+            content.style.width = sequencer.settings.content.width+"px";
+            content.style.height = sequencer.settings.content.height+"px";
+            addClass(content, "horizontal");
+            break;
+        case "survey":
+            sequencer.settings.content.orientation = "vertical";
+            sequencer.settings.content.width = 800;
+            sequencer.settings.content.height = "auto";
+            content.style.width = sequencer.settings.content.width+"px";
+            content.style.height = sequencer.settings.content.height+"px";
+            addClass(content, "vertical");
+            break;
+        default:
+            break;
+    }
+    fContentType.parentNode.parentNode.removeChild(fContentType.parentNode);
+}
+
+// Updating, drawing, formatting
 
 function updateSequencer() {
+    // Code that manages drawing and adding of new visual representations of objects in the sequencer.
 
     /*
-     * Description:
-     * This function updates the visual elements in the sequencer content view to match the current state of the sequencer.session.pipeline property.
-     * It queries the database for object properties via AJAX (returnStep/Display/.php), then inserts divider div's in between where needed.
-     */
-    var content = document.getElementById("seqContentWrapper");
+         * Description:
+         * This function updates the visual elements in the sequencer content view to match the current state of the sequencer.session.pipeline property.
+         * It queries the database for object properties via AJAX (returnStep/Display/.php), then inserts divider div's in between where needed.
+         */
+        
+    switch (sequencer.settings.content.contentType.toLowerCase()) {
+        case "session":
+            updateSequencer_Session();
+            break;
+        case "survey":
+            updateSequencer_Survey();
+            break;
+        default:
+            // Why would this even be called?
+            break;
+    }
+    
+    
+    
+    
+    //console.log(sequencer);
+    sequencer.state.updating = false;   // Re-enable new actions
+}
+
+function updateSequencer_Session() {
+    var content = ge("seqContentWrapper");
     var requestString, needsUpdating;
     var args;
+    
     if (sequencer.state.loaded == false || sequencer.settings.efficientUpdating == false) {  // This is the first update of the sequencer since page load, therefore it contains no previous steps
         // Stop running this function if the pipeline does not contain any elements to draw
@@ -140,5 +215,5 @@
         }, true);
         sequencer.state.loaded = true;
-        var loadingGif = document.createElement("div");
+        var loadingGif = ce("div");
         loadingGif.innerHTML = "<img src='images/ui/ajax-loader-round.gif' style='float: left; margin:auto auto;' />";
         content.appendChild(loadingGif);
@@ -165,5 +240,5 @@
         // Optional bit with the loading GIF
         for (var i = 0; i < needsUpdating.length; i++) {
-            var loadingDiv = document.createElement("div");
+            var loadingDiv = ce("div");
             loadingDiv.className = "displayStep loading";
             loadingDiv.innerHTML = "<img src='images/ui/ajax-loader-round.gif' />";
@@ -179,61 +254,138 @@
     // End optional
     }
-    console.log(sequencer);
-    sequencer.state.updating = false;   // Re-enable new actions
-}
-
-function loadSequencer() {
-    /* 
-     * Description:
-     * Load data from hidden fields (put there by PHP), store them in the global var "sequencer" (as well as several initialization properties),
-     * then remove the hidden fields from the HTML document tree.
-     */
-    
-    // Load hidden fields and set required properties in global object var.
-    
-    try {
-        // settings fields first
-        initEditor();
-        
-        // Content-related fields next
-        var fPipelineString = document.getElementById("pipelineStringField");
-        var fPipelineTypes = document.getElementById("pipelineTypeField");
-        var fSessionUid = document.getElementById("sessionField");
-        var fSessionTitle = document.getElementById("sessionTitleField");
-        debugger;
-        sequencer.session.title = fSessionTitle.value;
-        sequencer.session.uid = fSessionUid.value;
-        sequencer.session.pipeline.uids = stringToArray(fPipelineString.value, ",");
-        sequencer.session.pipeline.types = stringToArray(fPipelineTypes.value, ",");
-        sequencer.session.pipeline.upToDate = new Array();
-        
+}
+
+// THIS NEEDS SOME WORK! A LOT OF IT ACTUALLY!
+function updateSequencer_Survey() {
+    //debugger;
+    var content = ge("seqContentWrapper");
+    var requestString, needsUpdating, args;
+    // Create a reference to the correct field, this might not be needed if we do not generalize the updateSequencer function and instead keep two separate update functions for separate content types.
+    var variables = sequencer.survey;
+    
+    if (sequencer.state.loaded == false || sequencer.settings.efficientUpdating == false) {  // This is the first update of the sequencer since page load, therefore it contains no previous steps
+        // Stop running this function if the questions array does not contain any elements to draw
+        if (sequencer.survey.questions.uids.length == 0 || !sequencer.survey.questions.uids.length) return;
+        // First clear the entire content wrapper, just for safety and in case efficientUpdating is off
+        while (content.firstChild) {
+            content.removeChild(content.firstChild);
+        }
+        args = [];
+        needsUpdating = [];
+        for (var i = 0; i < sequencer.survey.questions.uids.length; i++) {
+            args.push({
+                uid: sequencer.survey.questions.uids[i],
+                type: "Question"
+            });
+            needsUpdating.push(new Array(i, sequencer.survey.questions.uids[i], "Question"));
+        }
+        
+        requestString = "args="+JSON.stringify(args);
+        newAjaxRequest(requestString, "returnObjectDisplay.php", function(result){
+            //debugger;
+            content.removeChild(loadingGif);
+            insertNewObjects(result.responseText, needsUpdating);
+        }, true);
+        sequencer.state.loaded = false;
+        var loadingGif = ce("div");
+        loadingGif.innerHTML = "<img src='images/ui/ajax-loader-round.gif' style='float: left; margin:auto auto;' />";
+        content.appendChild(loadingGif);
+    }
+    else {
+        // This means that one or more steps are being added, not an entire pipeline's worth of them
+        needsUpdating = new Array();
+        args = [];
+        // Add steps that need updating to the needsUpdating array (index, uid, type).
         for (var i = 0; i < sequencer.session.pipeline.uids.length; i++) {
-            sequencer.session.pipeline.upToDate.push(true);
-        }
-        sequencer.state.numSteps = 0;
-        sequencer.state.loaded = false;
-        sequencer.settings.efficientUpdating = true;
-    }
-    catch (e) {
-        // Alert developer of any errors while setting these variables
-        for (error in e) alert(error.message);
-    }
-    
-    // Then remove the hidden fields from the HTML document
-    // First reset the values to prevent them from being cached.
-    fPipelineString.value = "blaat";
-    fPipelineTypes.value = "blaat2";
-    fSessionUid.value = "blaat3";
-    fSessionTitle.value = "blaat4";
-    
-    var hiddenInputs = document.getElementById("hiddenInputs");
-    hiddenInputs.parentNode.removeChild(hiddenInputs);
-    
-    // finally, run updateSequencer to refresh the visual display of the pipeline
-    
-    updateSequencer();
+            if (sequencer.session.pipeline.upToDate[i] == true) continue;
+            needsUpdating.push(new Array(i, sequencer.session.pipeline.uids[i], sequencer.session.pipeline.types[i]));
+            args.push({
+                uid: sequencer.session.pipeline.uids[i],
+                type: sequencer.session.pipeline.types[i]
+            });        
+        }
+        
+        requestString = "args="+JSON.stringify(args);
+        newAjaxRequest(requestString, "returnObjectDisplay.php", function(result){
+            insertNewObjects(result.responseText, needsUpdating);
+        }, true);
+        
+        // Optional bit with the loading GIF
+        for (var i = 0; i < needsUpdating.length; i++) {
+            var loadingDiv = ce("div");
+            loadingDiv.className = "displayStep loading";
+            loadingDiv.innerHTML = "<img src='images/ui/ajax-loader-round.gif' />";
+            if (needsUpdating[i][0] > sequencer.state.numSteps-1) {
+                content.appendChild(loadingDiv);
+                sequencer.state.numSteps++;
+            }
+            else {
+                content.replaceChild(loadingDiv, content.childNodes[i][0]*2);
+            }
+        }
+        updateDividers();
+    // End optional
+    }
+}
+
+function updateDividers() {
+    // Function that checks for correct number of dividers in the pipeline, adds or deletes as needed.
+    
+    var content = ge("seqContentWrapper");
+    // Loop through all elements in seqContentWrapper
+    for (var i = 0; i < content.childNodes.length; i++) {
+        var element = content.childNodes[i];
+        // If the element is not a displayStep, continue with the next childNode.
+        if (!hasClass(element, "displayStep")) {
+            continue;
+        }
+        // Get the two elements next to the current element, if they don't exist or are not displaySteps, store false.
+        var lastElement = (element.previousSibling && element.previousSibling.nodeName == "DIV") ? element.previousSibling : false;
+        var nextElement = (element.nextSibling && element.nextSibling.nodeName == "DIV") ? element.nextSibling : false;
+        // If these elements exist, and they are not dividers, add an element in between.
+        if (lastElement != false) {
+            if (!hasClass(lastElement, "divider")){
+                var newDivider = ce("div");
+                addClass(newDivider, "divider");
+                addClass(newDivider, sequencer.settings.content.orientation);
+                content.insertBefore(newDivider, element);
+                delete newDivider;
+            }
+        }
+        if (nextElement != false) {
+            if (!hasClass(nextElement, "divider")){
+                var newDivider = ce("div");
+                addClass(newDivider, "divider");
+                addClass(newDivider, sequencer.settings.content.orientation);
+                content.insertBefore(newDivider, nextElement);
+                delete newDivider;
+            }
+        }
+    }
+}
+
+// Adding new objects
+
+function submitToolbox(type) {
+    // Handles new object creation code when user clicks on a toolbox button
+    
+    // Do not accept new creation requests if the sequencer is still updating a previous object.
+    if (sequencer.state.updating == true) return;
+    sequencer.state.updating = true;
+    deselectStep();    
+    var c = "objectToCreate="+type;
+    var u = "createObject.php";
+        
+    newAjaxRequest(c, u, function(result) {
+        sequencer.session.pipeline.uids.push(removeNL(result.responseText));
+        sequencer.session.pipeline.types.push(type);
+        sequencer.session.pipeline.upToDate.push(false);
+        updateSequencer();
+    }, true);
 }
 
 function insertNewObjects(responseText, needsUpdating) {
+    // Container function that calls different insertNewX() functions depending on content type. Called from updateSequencer().
+    debugger;
     var response = JSON.parse(responseText);
     // For now I assume that only one type of element can be displayed in the editor at one time. Therefore, the type of response[0] is the type of all elements of response.
@@ -251,13 +403,30 @@
 }
 
+function addQuestion_Click() {
+    if (sequencer.state.updating == true) return;
+    sequencer.state.updating = true;
+    deselectStep();    
+    var c = "objectToCreate=question";
+    var u = "createObject.php";
+        
+    newAjaxRequest(c, u, function(result) {
+        debugger;
+        sequencer.survey.questions.uids.push(removeNL(result.responseText));
+        sequencer.survey.questions.upToDate.push(false);
+        updateSequencer();
+    }, true);
+}
+
+//> Session specific
+
 function insertNewSteps(response, needsUpdating) {
     /*
-     * This is a test function displaying how to handle the visual object representation in solely javascript.
-     * Communication of relevant variables between PHP and JS happens in JSON format.
-     * PHP returns a JSON array of objects to be created by JS
-     * JS then loops through this array and creates DIVS to be inserted into the sequencer.
-     * These are inserted at the position needsUpdating gives us.
-     */
-    var content = document.getElementById("seqContentWrapper");
+         * This is a function displaying how to handle the visual object representation in solely javascript.
+         * Communication of relevant variables between PHP and JS happens in JSON format.
+         * PHP returns a JSON array of objects to be created by JS
+         * JS then loops through this array and creates DIVS to be inserted into the sequencer.
+         * These are inserted at the position needsUpdating gives us.
+         */
+    var content = ge("seqContentWrapper");
     // Remove optional loading images
     for (var  i = 0; i < content.childNodes.length; i++) {
@@ -269,17 +438,17 @@
     
     for (var i = 0; i < response.length; i++) {
-        var tempDiv = document.createElement("div");
+        var tempDiv = ce("div");
         tempDiv.id = response[i].uid;
         tempDiv.className = "displayStep";
-        var divImageContainer = document.createElement("div");
+        var divImageContainer = ce("div");
         divImageContainer.className = "displayStepIcon";
         divImageContainer.addEventListener("click", function(){
             clickStep(this.parentNode.id); 
         }, false);
-        var divImage = document.createElement("img");
+        var divImage = ce("img");
         divImage.src = "images/icons/"+response[i].type.toLowerCase()+".png";
         divImageContainer.appendChild(divImage);
         tempDiv.appendChild(divImageContainer);
-        var divLabel = document.createElement("p");
+        var divLabel = ce("p");
         divLabel.innerHTML = response[i].title;
         tempDiv.appendChild(divLabel);
@@ -301,15 +470,62 @@
 }
 
+function deleteStep() {
+    // Delete a step from both the pipeline.uids variable and its visual representation from the sequencer. Does not actually delete object from database!
+    
+    // check if a step is selected
+    if (sequencer.state.selectedObject.uid == null) {
+        return;
+    }
+    var uid = sequencer.state.selectedObject.uid;
+    // deselect the step to reset the info panel and selection code
+    deselectStep();
+    // splice the step's data from the pipeline
+    var index = sequencer.session.pipeline.uids.indexOf(uid);
+    if (index >= 0 && index < sequencer.session.pipeline.uids.length) {
+        sequencer.session.pipeline.uids.splice(index, 1);
+        sequencer.session.pipeline.types.splice(index, 1);
+        sequencer.session.pipeline.upToDate.splice(index, 1);
+        // Then delete the step visually
+        var element = ge(uid);
+        var divider;
+        if (!element.nextSibling) {
+            // the element is at the end of the pipeline
+            // therefore we remove the previous divider.
+            // Note: it could also be the only element left in the pipeline!
+            divider = (element.previousSibling) ? element.previousSibling : false;
+            if (divider != false) {
+                divider.parentNode.removeChild(divider);
+            }
+        }
+        else {
+            // the element is at any position except the last, therefore we remove the next divider
+            divider = (element.nextSibling) ? element.nextSibling : false;
+            if (divider != false) {
+                divider.parentNode.removeChild(divider);
+            }
+        }
+        
+        // Finally, remove the element itself.
+        element.parentNode.removeChild(element);
+        sequencer.state.numSteps--;
+        
+    }
+}
+
+//> Survey specific
+
 function insertNewQuestions(response, needsUpdating) {
-    var content = document.getElementById("seqContentWrapper");
+    //Code that inserts or replaces new object displays in the sequencer. Question version.
+    
+    var content = ge("seqContentWrapper");
     // Loop through returned question objects
     for (var i = 0; i < response.length; i++) {
         // Define the outer frame
-        var frameDiv = document.createElement("div");
+        var frameDiv = ce("div");
         frameDiv.className = "smallFrame question";
         frameDiv.id = response[i].uid;
-        var titleDiv = document.createElement("div");
+        var titleDiv = ce("div");
         titleDiv.className = "smallTitle";
-        var numberDiv = document.createElement("div");
+        var numberDiv = ce("div");
         numberDiv.className = "listNumber";
         numberDiv.innerHTML = i.toString();
@@ -320,5 +536,5 @@
         // The frame now has a header bar
         // On to the content frame
-        // Will use new "ce();" function, shorthand for document.createElement
+        // Will use new "ce();" function, shorthand for ce
         
         var contentDiv = ce("div");
@@ -366,36 +582,67 @@
 }
 
-function updateDividers() {
-    var content = document.getElementById("seqContentWrapper");
-    for (var i = 0; i < content.childNodes.length; i++) {
-        var element = content.childNodes[i];
-        if (!hasClass(element, "displayStep")) {
-            continue;
-        }
-        var lastElement = (element.previousSibling && element.previousSibling.nodeName == "DIV") ? element.previousSibling : false;
-        var nextElement = (element.nextSibling && element.nextSibling.nodeName == "DIV") ? element.nextSibling : false;
-        if (lastElement != false) {
-            if (!hasClass(lastElement, "divider")){
-                var newDivider = document.createElement("div");
-                addClass(newDivider, "divider");
-                addClass(newDivider, sequencer.settings.content.orientation);
-                content.insertBefore(newDivider, element);
-                delete newDivider;
-            }
-        }
-        if (nextElement != false) {
-            if (!hasClass(nextElement, "divider")){
-                var newDivider = document.createElement("div");
-                addClass(newDivider, "divider");
-                addClass(newDivider, sequencer.settings.content.orientation);
-                content.insertBefore(newDivider, nextElement);
-                delete newDivider;
-            }
-        }
-    }
+// general functions and user actions
+
+function clickStep(uid) {
+    // Handles selection of steps
+    
+    if (uid == sequencer.state.selectedObject.uid) {  // user deselected a currently selected step.
+        deselectStep();
+    }
+    else {
+        if (sequencer.state.selectedObject.uid != undefined && sequencer.state.selectedObject.uid != "") {
+            // Change selection if something is already selected
+            deselectStep();
+            selectStep(uid);
+        }
+        else {
+            // Make new selection if nothing was selected
+            selectStep(uid);
+        }        
+    }
+}
+
+function selectStep(uid) {
+    // Called from clickStep(), manages CSS class assignment and updating of state variables. Also calls for info panel update.
+    
+    var element = ge(uid);
+    if (element) {
+        addClass(element, "selected");
+        var type = sequencer.session.pipeline.types[sequencer.session.pipeline.uids.indexOf(uid)];
+        ajaxInfoRequest(uid, ge("infoPanelContent"), type);
+        sequencer.state.selectedObject.uid = uid;
+        sequencer.state.selectedObject.index = null;  //Don't know how to do this yet.
+    }
+}
+
+function deselectStep() {
+    // Called from clickStep(). Handles unassignment and updating of state variables. Clears info panel.
+    
+    if (!sequencer.state.selectedObject.uid) return;
+    var element = ge(sequencer.state.selectedObject.uid);
+    removeClass(element, "selected");
+    sequencer.state.selectedObject.uid = null;
+    sequencer.state.selectedObject.index = null;
+    var infoPanel = ge("infoPanelContent");
+    if (infoPanel) {
+        while (infoPanel.firstChild) infoPanel.removeChild(infoPanel.firstChild);
+    }
+}
+
+function ajaxInfoRequest(uid, el, type) {
+    // Info panel update.
+    
+    var c = "uid="+uid;
+    c += "&type="+type;
+    var u = "getInfo.php";
+    newAjaxRequest(c, u, function(result) {
+        el.innerHTML = result.responseText;
+    }, true);
 }
 
 function savePipeline (confirmSave) {
-    
+    // Sends an AJAX request to the PHP server that saves the current pipeline. Does not yet support surveys.
+    
+    // First check if user should confirm save action or not.
     var answer;
     if (confirmSave == true) {
@@ -406,5 +653,6 @@
     }
     if (answer == false) return;
-    
+    // Then compose requestString for savesession.php, containing pipeline uids, types and the session uid.
+    // TODO: should eventually include stuff like session name as well!
     var requestString = "uids=";
     requestString += arrayToString(sequencer.session.pipeline.uids, ",");
@@ -422,16 +670,17 @@
 
 function editStep() {
+    // Redirects the browser to the appropriate editor for the selected step type.
+    
     // first save
-    
-    //savePipeline(false);
-    
-    var postForm = document.createElement("form");
-    var type = sequencer.session.pipeline.types[sequencer.session.pipeline.uids.indexOf(sequencer.state.selectedStep.uid)];
+    savePipeline(false);
+    // Then post relevant information so the next editor page knows what object it is supposed to be editing.
+    var postForm = ce("form");
+    var type = sequencer.session.pipeline.types[sequencer.session.pipeline.uids.indexOf(sequencer.state.selectedObject.uid)];
     postForm.action = type.toLowerCase()+"Editor.php";
     postForm.method = "POST";
-    var objectUid = document.createElement("input");
+    var objectUid = ce("input");
     objectUid.type = "hidden";
     objectUid.name = "objectUid";
-    objectUid.value = sequencer.state.selectedStep.uid;
+    objectUid.value = sequencer.state.selectedObject.uid;
     postForm.appendChild(objectUid);
     postForm.submit();
@@ -439,8 +688,10 @@
 
 function moveStep (direction) {
+    // Moves the selected step up/down (left/right) in the pipeline.
+    
     // Check if a step is selected
-    if (sequencer.state.selectedStep.uid == null || direction == null) return;
+    if (sequencer.state.selectedObject.uid == null || direction == null) return;
     // Check if the step is not at either end of the pipeline
-    var index = sequencer.session.pipeline.uids.indexOf(sequencer.state.selectedStep.uid);
+    var index = sequencer.session.pipeline.uids.indexOf(sequencer.state.selectedObject.uid);
     if (index == -1) return;
     if ((index < 0) || (index >= sequencer.session.pipeline.uids.length) || (index == 0 && direction == -1) || (index == sequencer.session.pipeline.uids.length - 1 && direction == 1)) {
@@ -450,11 +701,11 @@
     
     // Find the two elements in the editor content display
-    var content = document.getElementById("seqContentWrapper");
-    var element = document.getElementById(sequencer.session.pipeline.uids[index]);
-    var otherElement = document.getElementById(sequencer.session.pipeline.uids[index+direction]);
+    var content = ge("seqContentWrapper");
+    var element = ge(sequencer.session.pipeline.uids[index]);
+    var otherElement = ge(sequencer.session.pipeline.uids[index+direction]);
     // First buffer the two elements
     var tempElement = element.cloneNode(true);
     var tempOtherElement = otherElement.cloneNode(true);
-    var placeHolderElement = document.createElement("div");
+    var placeHolderElement = ce("div");
     placeHolderElement.id = "placeholder_element";
     content.replaceChild(placeHolderElement, otherElement);
@@ -501,37 +752,18 @@
 }
 
-function initEditor() {
-    // Reset the editor if the 
-    
-    // load settings fields first
-    var fContentType = document.getElementById("sContentTypeField");
-    var content = document.getElementById("seqContent");
-    //sequencer.settings.content.contentType = fContentType.value.toLowerCase();
-    sequencer.settings.content.contentType = fContentType.value;
-    //Then select settings from a few presets
-    
-    switch (sequencer.settings.content.contentType) {
-        case "session":
-            sequencer.settings.content.orientation = "horizontal";
-            sequencer.settings.content.width = 800;
-            sequencer.settings.content.height = 125;
-            content.style.width = sequencer.settings.content.width+"px";
-            content.style.height = sequencer.settings.content.height+"px";
-            addClass(content, "horizontal");
-            break;
-        case "survey":
-            sequencer.settings.content.orientation = "vertical";
-            sequencer.settings.content.width = 800;
-            sequencer.settings.content.height = "auto";
-            content.style.width = sequencer.settings.content.width+"px";
-            content.style.height = sequencer.settings.content.height+"px";
-            addClass(content, "vertical");
-            break;
-        default:
-            break;
-    }
-    fContentType.parentNode.parentNode.removeChild(fContentType.parentNode);
-}
-
+// WORK IN PROGRESS
+
+
+
+
+
+
+
+
+/******************/
+/* TEMP FUNCTIONS */
+/******************/
+
+// Temp function that creates a dummy question to test the insertNewQuestions function.
 function debug_addQuestion() {
     // Derp, natuurlijk werkt de addQuestion call niet twee keer. Hij creeert twee keer exact hetzelfde object. Bottom line: het werkt. Nu de editing code voor deze questions gaan schrijven!
@@ -552,4 +784,5 @@
 }
 
+// Temp function that articially switches content type when the page is already loaded, to easily test layout changes and content flow.
 function debug_switchType() {
     var content = ge("seqContent");
@@ -569,46 +802,2 @@
     }
 }
-
-function createVarArray() {
-    if (sequencer) delete window.sequencer;
-    return {   // GLOBAL VAR TO STORE SEQUENCER SETTINGS!
-        uid: "",                // The unique id of this sequencer (not DB related!). This will help to avoid global var conflicts. Assign this randomly! (STRING)
-        session: {              // Properties of the currently loaded session
-            title: "",              // Title or name (STRING)
-            uid: "",                // Database UID of the current session (STRING)
-            pipeline: {             // Pipeline
-                uids: [],               // Uids of objects in pipeline (STRING)
-                types: [],              // Types of objects in pipeline (STRING)
-                upToDate: []            // Whether or not object displays are up to date (BOOL)
-            }
-        },
-        survey: {               // Properties of the loaded survey, if applicable (either this or the session tree above is filled in!) [THIS IS NOT CURRENTLY USED AND I SHOULD DELIBERATE ON WHAT VARIABLES TO PUT IN THIS TREE TO MAKE A FUNCTIONAL EDITOR THAT ALSO MATCHES THE DB FORMAT!]
-            title: "",              // Title or the name of the survey
-            uid: "",                // Uid of the survey
-            questions: {            // Properties of the questions contained within this survey
-                uids: [],               // An array of uids of the questions, in the order that they appear in the survey
-                upToDate: []            // Whether or not a certain question needs an update
-            }
-        },
-        state: {                // Operating state of the sequencer
-            editing: false,         // Whether or not one of the contained child objects is currently being edited or in edit mode. Which one can be determined from the selectedStep property.
-            updating: false,        // Whether or not new steps are currently being queried (to disable any further actions)
-            numSteps: 0,            // Number of steps currently drawn in the editor (not necessarily same as number of steps in pipeline!) (INTEGER)
-            loaded: false,          // Whether or not the sequencer content has been updated for the first time (BOOL)
-            selectedStep: {         // Properties of the currently selected step
-                uid: "",                // UID of this step (STRING)
-                index: null             // The 'index' of this step in the current sequencer view (NOT the pipeline!) (INTEGER)
-            }        
-        },
-        settings: {             // Various settings to determine the workings of the sequencer
-            content: {              // Properties related to the content view of the sequencer
-                contentType: null,      // Type of the loaded parent object (STRING)
-                width: null,            // Width of the viewing area (INTEGER)
-                height: null,           // Height of the viewing area (INTEGER)
-                maxObjects: null,       // The maximum number of content elements to be displayed at once time (INTEGER)
-                orientation: null       // Whether the editor should be a vertical or horizontal editor (STRING)
-            },
-            efficientUpdating: true // Whether or not to use selective querying of the database for new step objects. True will only refresh out-of-date steps, False will refresh the whole pipeline
-        }
-    };
-}
Index: Dev/trunk/pipelineEditor.php
===================================================================
--- Dev/trunk/pipelineEditor.php	(revision 184)
+++ Dev/trunk/pipelineEditor.php	(revision 185)
@@ -7,5 +7,5 @@
 
 $sequencer = new PipelineSequencer();
-$sequencer->LoadSession($_SESSION['currentSession']); //load session into php part of the sequencer
+$sequencer->LoadSession(); //load session into php part of the sequencer
 $sequencer->HandlePostData();
 ?>
@@ -30,6 +30,4 @@
         <div id="header">
             <?php new Logo(); ?>
-            <input type="button" onClick="debug_switchType();" value="debug_switchType()" />
-            <input type="button" onClick="debug_addQuestion();" value="debug_addQuestion()" />
         </div>
 
Index: Dev/trunk/returnObjectDisplay.php
===================================================================
--- Dev/trunk/returnObjectDisplay.php	(revision 184)
+++ Dev/trunk/returnObjectDisplay.php	(revision 185)
@@ -3,9 +3,14 @@
 require 'classes/master.php';
 
-//var_dump($_POST);
-if (isset($_POST['args']) && !empty($_POST['args'])) {
+/* 
+ * Note: do not try to implement info panel displays in this file as well, it passes and queries a lot of data that you really do not need.
+ * Since this function will be used so often, adding extra unneeded code to it will slow down the regular operation of the editor (refreshes, etc..) while not offering a significant advantage over the existing getInfo.php
+ */
+
+
+if(isset($_POST['args']) && !empty($_POST['args'])) {
     // Get arguments and convert to object
     $input = $_POST['args'];
-    $inputDecoded = json_decode($input);
+    $requestArray = json_decode($input);
 } else {
     die('DOESNT WORK...');
@@ -14,6 +19,17 @@
 $dbi = new DatabaseInterface();
 $outputArray = array();
-foreach ($inputDecoded as $request) {
-    $results = $dbi->get($request->type, array("uid" => $request->uid));
+foreach ($requestArray as $request) {
+    var_dump($request);
+    $results = $dbi->get(strtolower($request->type), array("uid" => $request->uid));
+    
+    /*
+     * Reden voor deze var dumps is dat de questions niet gevonden kunnen worden. De bovenstaande regel returnet geen question object, ook als deze zeker weten wel bestaat.
+     * Even aan Jos vragen wat hier fout gaat?
+     */
+    
+    
+    
+    
+    var_dump($results);
     if (isset($results) && !empty($results)) {
         is_array($results) ? $object = $results[0] : $object = $results;
Index: Dev/trunk/selectSession.php
===================================================================
--- Dev/trunk/selectSession.php	(revision 184)
+++ Dev/trunk/selectSession.php	(revision 185)
@@ -45,4 +45,5 @@
         $matching = $dbi->get("SESSION", array("uid" => $_POST['sessionUID']));
         if (count($matching) == 1 && $matching[0] != null) {
+            // DEZE SESSION MOET UITEINDELIJK EEN POST WORDEN, WANNEER DEZE HELE PAGINA IS OVERGEZET IN JAVASCRIPT!
             $_SESSION['currentSession'] = $_POST['sessionUID'];
             $_SESSION['updateNeeded'] = "true";
Index: Dev/trunk/surveyEditor.php
===================================================================
--- Dev/trunk/surveyEditor.php	(revision 184)
+++ Dev/trunk/surveyEditor.php	(revision 185)
@@ -25,4 +25,7 @@
                 <?php $surveyEditor->init(); ?>
             </div>
+            <div id="settingsFields">
+                <input type="hidden" id="sContentTypeField" value="Survey" />
+            </div>
         </div>
     </body>
