Index: v/trunk/classes/DisplayStep.php
===================================================================
--- /Dev/trunk/classes/DisplayStep.php	(revision 153)
+++ 	(revision )
@@ -1,52 +1,0 @@
-<?php
-
-/**
- * DisplayStep object is the visual representation of an existing step in a pipeline, to be displayed in the pipeline sequencer.
- * Note: Can also be used for creation icons in the Toolbox, as long as no reference to an existing step object is assigned.
- * 
- * IMPORTANT: DisplayStep() should only be used to graphically display a certain Step object. 
- * It only contains a reference to an existing object ($reference), and is not the database object itself!
- * General idea: handle real objects privately, only generate DisplaySteps() based on that data, not the other way around.
- *
- * @author tschipper
- */
-class DisplayStep {
-
-//put your code here
-    private $type;
-    private $reference;
-    public $imageURL;
-    public $selected = false;
-    public $caption;
-    public $id;
-
-    public function __construct($t, $ref=null, $c, $id) {
-
-        $this->type = $t;
-        $this->reference = $ref;
-        $this->caption = $c;
-        $this->id = $id;
-
-        switch ($this->type) {
-            case "Questionnaire":
-                $this->imageURL = "images/icons/questionnaire.png";
-                break;
-            case "Dashboard":
-                $this->imageURL = "images/icons/dashboard.png";
-                break;
-            case "Application":
-                $this->imageURL = "images/icons/application.png";
-                break;
-            default:
-                $this->imageURL = null;
-                break;
-        }
-
-        //output a display object
-        //echo '<div class="displayStep"><div class="displayStepIcon" style="background-image: url('.$this->imageURL.');"></div>'.$this->caption.'</div>'."\n";
-        echo '<div class="displayStep" onClick="checkSelectedStep('.$this->id.');"><div class="displayStepIcon"><img src="' . $this->imageURL . '" /></div>' . $this->caption . '</div>';
-    }
-
-}
-
-?>
Index: v/trunk/classes/Step.php
===================================================================
--- /Dev/trunk/classes/Step.php	(revision 153)
+++ 	(revision )
@@ -1,63 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Placeholder class, for testing of pipelineEditor.php only.
- * Will eventually be replaced by functioning Questionnaire, Notice, Dashboard and Application objects in array steps[].
- *
- * @author Thijs Schipper
- */
-class Step {
-
-    public $type;
-    public $name;
-    public $uid;
-    // merging step and displayStep
-
-    public $imageURL;
-
-    public function __construct($type, $name, $uid) {
-
-        // check if type given is valid, set internal variables
-        if (strtolower($type) == "application" || strtolower($type) == "dashboard" || strtolower($type) == "questionnaire") {
-            $this->type = strtolower($type);
-            $this->name = strtolower($name);
-            $this->id = strtolower($uid);
-        } else {
-            die("Invalid type given: " . $type . "\n $name $uid");
-        }
-
-        // assign relevant icon
-        switch ($this->type) {
-            case "questionnaire":
-                $this->imageURL = "images/icons/questionnaire.png";
-                break;
-            case "dashboard":
-                $this->imageURL = "images/icons/dashboard.png";
-                break;
-            case "application":
-                $this->imageURL = "images/icons/application.png";
-                break;
-            default:
-                $this->imageURL = "images/icons/unknowntype.png";
-                break;
-        }
-    }
-
-    public function init() {
-        if (isset($this->type) && isset($this->imageURL) && isset($this->name)) {
-            ?>
-            <div class="displayStep" onClick="checkSelectedStep('<?php echo $this->id; ?>');"><div class="displayStepIcon"><img src="<?php echo $this->imageURL; ?>" /></div><?php echo $this->name; ?></div>
-            <?php
-        }
-    }
-
-    public function AdjustID($offset) {
-        $this->id += $offset;
-    }
-
-}
-?>
Index: /Dev/trunk/classes/Toolbox.php
===================================================================
--- /Dev/trunk/classes/Toolbox.php	(revision 153)
+++ /Dev/trunk/classes/Toolbox.php	(revision 154)
@@ -20,5 +20,5 @@
                 <div class="title">Toolbox</div>
                 <p>Add new: </p>
-                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Questionnaire'; SubmitToolbox();"><img src="images/icons/questionnaire.png" class="buttonIcon"/><p>Questionnaire</p></div>
+                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Survey'; SubmitToolbox();"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>
                 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Application'; SubmitToolbox();"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div>
                 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>
Index: /Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- /Dev/trunk/classes/pipelineSequencer.php	(revision 153)
+++ /Dev/trunk/classes/pipelineSequencer.php	(revision 154)
@@ -27,11 +27,9 @@
         $stringPipeline = rtrim($stringPipeline, ",");
         ?>
-        <br /><form name="sequencer" action="pipelineEditor.php" method="post">
+        <br /><form name="sequencerForm" action="pipelineEditor.php" method="post">
             <fieldset id="sequencer">
                 <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div>
 
-                <div id="seqContent">
-
-                </div>
+                <div id="seqContent"></div>
 
                 <div id="controls">
@@ -43,7 +41,7 @@
                     <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
                 </div>
-                <div id="hiddeInputs">
+                <div id="hiddenInputs">
                     <input type="hidden" name="selectedStep" id="selectedStepField" value="" />
-                    <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456,123" />
+                    <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456" />
                 </div>
             </fieldset>
@@ -66,7 +64,6 @@
     public function Javascript() {
         $pipelineString = "ERROR";
-        
+
         echo "<!--$pipelineString-->";
-        
         ?>
         <script type="text/javascript" src="js/sequencerScripts.js"></script>
@@ -90,9 +87,62 @@
         if (count($sessionResults) > 0) {
             $this->loadedSession = $sessionResults[0];
-        } else {
+        } else {        //No session with that UID found in database!
             die("Invalid session!");
         }
     }
 
+    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'])) {
+                MoveStep($_POST['selectedStep'], -1);
+            }
+        }
+
+        if (isset($_POST['moveSelectedRight'])) {
+            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
+                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;
+            }
+        }
+    }
+
+    // Dit is een pure php versie. Deze slaat nog niet op in de Database, en reageert nog niet op 
+    public function MoveStep($uid, $direction) {
+        $newSession = $this->loadedSession;
+
+        for ($i = 0; $i < count($newSession->pipeline); $i++) {
+            if ($newSession->pipeline[i]->uid == $uid) {
+                $temp = $newSession->pipeline[i];
+                $newSession->pipeline[i] = $newSession->pipeline[i + $direction];
+                $newSession->pipeline[i + $direction] = $newSession->pipeline[i];
+                break;
+            }
+        }
+
+        $this->loadedSession = $newSession;
+    }
+
 }
 ?>
Index: /Dev/trunk/css/awesome.css
===================================================================
--- /Dev/trunk/css/awesome.css	(revision 153)
+++ /Dev/trunk/css/awesome.css	(revision 154)
@@ -668,5 +668,8 @@
 
 .displayStep.selected {
-    background-color: rgba(255, 255, 255, 0.5);
+    -moz-box-shadow: 0 0 50px #FFF;
+    -webkit-box-shadow: 0 0 50px #FFF;
+    box-shadow: 0 0 50px #FFF;
+    
 }
 
Index: /Dev/trunk/js/sequencerScripts.js
===================================================================
--- /Dev/trunk/js/sequencerScripts.js	(revision 153)
+++ /Dev/trunk/js/sequencerScripts.js	(revision 154)
@@ -32,5 +32,6 @@
 
 function hasClass(ele,cls) {
-    return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
+    if (ele.className)
+        return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
 }
  
@@ -50,18 +51,21 @@
 
 function selectStep(uid) {
-    document.getElementById(uid).addClass("selected");
-    var selectedInfo = document.getElementById("selectedStepField");
-    if (selectedInfo == null) {     // This is the first time a step is selected after a reload of the page, therefore a hidden input field is not yet present.
-        selectedInfo = document.createElement("input")
-        selectedInfo.setAttribute("type","hidden");
-        selectedInfo.setAttribute("id","selectedStepField");
-        selectedInfo.setAttribute("value",uid);
-        var hiddenInputFields = document.getElementById("hiddenInputs");
-        hiddenInputFields.appendChild(selectedInfo);
+    var nodes = document.getElementById("seqContent").childNodes;
+    for (var i = 0; i < nodes.length; i++) {     //loop through childNodes. Skip first node (whitespace)
+        //debugger;
+        if (hasClass(nodes[i], "displayStep")) {    //check if current childNode is a displayStep, not divider or text.
+            if (nodes[i].id == uid) {
+                addClass(nodes[i], "selected");
+            }
+            else {
+                removeClass(nodes[i], "selected");
+            }
+        }
     }
-    else {      // There already exists a hidden input field with id selectedStepField, therefore we only change the value of this field.
-        var hiddenInput = document.getElementById("selectedStepField");
-        hiddenInput.value = uid;
-    }
+    
+    // Update selected step field with uid of currently selected step.
+    var selectedStepField = document.getElementById("selectedStepField");
+    selectedStepField.value = uid;
+    
 }
                                                                             
@@ -123,4 +127,5 @@
 }
 
+
 /*
  * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
@@ -128,11 +133,9 @@
  */
 
-function ajaxStepRequest(UID) {
-    var c = "uid="+UID;
+function ajaxStepRequest(UIDS) {
+    var c = "uids="+UIDS;
     var u = "returnStep.php";
     newAjaxRequest(c, u, function(result) {
-        var newDiv = document.createElement("div");
-        newDiv.innerHTML = result.responseText;
-        document.getElementById("seqContent").appendChild(newDiv);
+        document.getElementById("seqContent").innerHTML = result.responseText;
     });
 }
@@ -156,17 +159,6 @@
     var content = document.getElementById("seqContent");
     var pipeline = document.getElementById("pipelineStringField").value;
-    var copy = pipeline;
-    pipeline = copy.split(",");
-    
-    // then do an xmlhttp request for each step to be added to the sequencer
-    var numberOfSteps = pipeline.length;
-    for (var i = 0; i < numberOfSteps; i++) {
-        ajaxStepRequest(pipeline[i]);
-        if (i < (numberOfSteps-1)) {
-            ajaxStepRequest("divider");
-        }
-    }
-    
-                
+    pipeline = pipeline.replace(/,/g , ",divider,");    //regex search for commas, global (repeat), to represent them with visual dividers.
+    ajaxStepRequest(pipeline);
 }
 
@@ -174,4 +166,2 @@
     
 }
-
-
Index: /Dev/trunk/pipelineEditor.php
===================================================================
--- /Dev/trunk/pipelineEditor.php	(revision 153)
+++ /Dev/trunk/pipelineEditor.php	(revision 154)
@@ -3,10 +3,10 @@
 
 if (!isset($_SESSION['username'])) {
-    $_SESSION['message'] = "You were redirected here because your session timed out or you used an invalid link.";
     redirect('index.php');
 }
 
 $sequencer = new PipelineSequencer();
-$sequencer->GetFromDB($_SESSION['currentSession']);
+$sequencer->GetFromDB($_SESSION['currentSession']); //load session into php part of the sequencer
+$sequencer->HandlePostData();
 ?>
 
Index: v/trunk/pipelineEditor_1.php
===================================================================
--- /Dev/trunk/pipelineEditor_1.php	(revision 153)
+++ 	(revision )
@@ -1,224 +1,0 @@
-<?php
-require 'classes/master.php'; //should be at top of every page
-
-/*  So far, the entire page works based on sessions.
- *  We want it to load the database stuff into the session on user load, and only write back to database when you exit the page.
- *  Is this possible with the current db model?
- * 
- */
-
-// Reset session, for debug purposes only!
-if (isset($_POST['resetSession'])) {
-    unset($_SESSION['steps']);
-    $_SESSION['selectedStep'] = null;
-}
-
-// Clear entire pipeline, confirm checkbox checked!
-if (isset($_POST['clearPipeline']) && isset($_POST['confirmClear'])) {
-    unset($_SESSION['steps']);
-    $_SESSION['steps'] = array();
-}
-
-// Upon first page load, generate a placeholder array of Steps. (Only string at the moment!)
-if (!isset($_SESSION['steps'])) {
-    $_SESSION['steps'] = array("Questionnaire 1", "Questionnaire 2", "Notice 1", "Application 1", "Dashboard 1");
-    $_SESSION['selectedStep'] = null;
-}
-
-// if user clicked "remove" button
-if (isset($_POST['removeStep'])) {
-    if (isset($_POST['pipelineContents'])) {        // if a step has been selected
-        $toBeRemoved = $_POST['pipelineContents'];
-        $tempArray = array();
-        foreach ($_SESSION['steps'] as $step) {
-            if ($step != $toBeRemoved) {
-                $tempArray[] = $step;
-            }
-        }
-        $_SESSION['steps'] = $tempArray;
-        unset($tempArray);
-        unset($toBeRemoved);
-        $_SESSION['selectedStep'] = null;
-    }
-}
-
-/*
- * 
- *  Object creating code
- *  
- */
-
-//  Questionnaire
-if (isset($_POST['createQuestionnaire'])) {
-    $n = 1;
-    while (in_array("Questionnaire $n", $_SESSION['steps'])) {
-        $n++;
-    }
-    $_SESSION['steps'][] = "Questionnaire $n";
-    $_SESSION['selectedStep'] = "Questionnaire $n";
-}
-
-//  Notice
-if (isset($_POST['createNotice'])) {
-    $n = 1;
-    while (in_array("Notice $n", $_SESSION['steps'])) {
-        $n++;
-    }
-    $_SESSION['steps'][] = "Notice $n";
-    $_SESSION['selectedStep'] = "Notice $n";
-}
-
-// Application
-if (isset($_POST['createApplication'])) {
-    $n = 1;
-    while (in_array("Application $n", $_SESSION['steps'])) {
-        $n++;
-    }
-    $_SESSION['steps'][] = "Application $n";
-    $_SESSION['selectedStep'] = "Application $n";
-}
-
-//  Dashboard
-if (isset($_POST['createDashboard'])) {
-    $n = 1;
-    while (in_array("Dashboard $n", $_SESSION['steps'])) {
-        $n++;
-    }
-    $_SESSION['steps'][] = "Dashboard $n";
-    $_SESSION['selectedStep'] = "Dashboard $n";
-}
-
-/*
- * 
- * Move up/down code
- * 
- */
-
-
-if (isset($_POST['moveUp'])) {          // if user clicked "Move up" button
-    if (isset($_POST['pipelineContents'])) {     // if user has selected a pipeline step
-        $arrayCopy = $_SESSION['steps'];     // copy session contents to local variable, to prevent messing up the session by accident
-        $key = array_search($_POST['pipelineContents'], $arrayCopy);     // find key of target entry in array
-        $_SESSION['selectedStep'] = $arrayCopy[$key];
-        moveEntry($arrayCopy, $key, -1);
-        $_SESSION['steps'] = $arrayCopy;
-    }
-}
-
-if (isset($_POST['moveDown'])) {          // if user clicked "Move up" button
-    if (isset($_POST['pipelineContents'])) {     // if user has selected a pipeline step
-        $arrayCopy = $_SESSION['steps'];     // copy session contents to local variable, to prevent messing up the session by accident
-        $key = array_search($_POST['pipelineContents'], $arrayCopy);     // find key of target entry in array
-        $_SESSION['selectedStep'] = $arrayCopy[$key];
-        moveEntry($arrayCopy, $key, 1);
-        $_SESSION['steps'] = $arrayCopy;
-    }
-}
-
-function moveEntry(&$array, $key, $dir) {
-    if ($dir == -1) {   // move up
-        if ($key > 0) {
-            $reverseArray = array_reverse(array_slice($array, $key - 1, 2, true));   // make a reversed array of the two entries, preserving keys
-            array_splice($array, $key - 1, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
-        }
-    } else if ($dir == 1) {   // move down
-        if ($key < count($array) - 1) {
-            $reverseArray = array_reverse(array_slice($array, $key, 2, true));   // make a reversed array of the two entries, preserving keys
-            array_splice($array, $key, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
-        }
-    }
-}
-
-/*
- * 
- *  Edit code
- * 
- */
-
-if (isset($_POST['editStep'])) {
-    editStep($_POST['pipelineContents']);
-}
-
-function editStep($step) {
-    $_SESSION['activeStep'] = $step;
-    switch (strtolower(substr($step, 0, strlen($step) - 2))) {
-        case "questionnaire":
-            redirect("editQuestionnaire.php?UID=$step->uid");
-            break;
-        case "notice":
-            redirect("editNotice.php?UID=$step->uid");
-            break;
-        case "application":
-            redirect("editApplication.php?UID=$step->uid");
-            break;
-        case "dashboard":
-            redirect("editDashboard.php?UID=$step->uid");
-            break;
-        default:
-            die("Invalid or no step type selected!");
-            break;
-    }
-}
-?>
-<!--
-To change this template, choose Tools | Templates
-and open the template in the editor.
--->
-<!DOCTYPE html>
-<html>
-    <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-        <title></title>
-        <?php new StyleSheet("awesome"); ?>
-        <script type="text/javascript" src="js/menu.js"></script>
-        <script type="text/javascript" src="js/jquery.js"></script>
-        <script type="text/javascript" src="js/editorScripts.js"></script>
-    </head>
-    <body onLoad="IsItemSelected(document.mainForm.pipelineContents, document.mainForm.editStep);">
-        <div id="header">
-            <?php new Logo(); ?>
-        </div>
-
-        <div id="wrapper">
-            <div id="content">
-                <form name ="mainForm" action="pipelineEditor_1.php" method="POST">
-                    <fieldset>
-                        <select name="pipelineContents" style="width: 300px;" size="8" onChange="IsItemSelected(this, document.mainForm.editStep);">
-                            <?php
-                            foreach ($_SESSION['steps'] as $step) {
-                                echo '<option value="' . $step . '" ';
-                                if ($step == $_SESSION['selectedStep']) {
-                                    echo 'selected ="selected"';
-                                }
-                                echo '>' . $step . '</option>' . "\n";
-                            }
-                            ?>
-
-
-                        </select>
-                        <input type="submit" name="editStep" value="Edit" disabled="true"/>
-                        <input type="submit" name="removeStep" value="Remove" />
-                        <input type="submit" name="moveUp" value="Move up" />
-                        <input type="submit" name="moveDown" value="Move down" />
-                        <input type="submit" name="clearPipeline" value="Clear pipeline" disabled="true"/>
-                        <input type="checkbox" name="confirmClear" onClick="IsCheckEnabled(this, document.mainForm.clearPipeline)"/> Really delete all?
-
-
-                    </fieldset>
-
-                    <fieldset>
-                        Add:
-                        <input type="submit" name="createQuestionnaire" value="Questionnaire" />
-                        <input type="submit" name ="createNotice" value="Notice" />
-                        <input type="submit" name="createApplication" value="Application" />
-                        <input type="submit" name="createDashboard" value="Dashboard" />
-                    </fieldset>
-
-                    <fieldset>
-                        <label>Debug</label>
-                        <input type="submit" name="resetSession" value="Reset Session" />
-                    </fieldset>
-                </form>
-            </div>
-    </body>
-</html>
Index: /Dev/trunk/returnStep.php
===================================================================
--- /Dev/trunk/returnStep.php	(revision 153)
+++ /Dev/trunk/returnStep.php	(revision 154)
@@ -10,9 +10,9 @@
 
 // Check if calling script actually passed a uid to use
-if (isset($_POST['uid'])) {
-    if (!empty($_POST['uid'])) {
-        $uid = $_POST['uid'];
+if (isset($_POST['uids'])) {
+    if (!empty($_POST['uids'])) {
+        $uids = $_POST['uids'];
     } else {
-        echo "Invalid UID passed!";
+        echo "Invalid UIDs passed!";
     }
 } else {
@@ -20,86 +20,100 @@
 }
 
+$sUids = explode(",", $uids);
+$response = "";
+$dbi = new DatabaseInterface();
+foreach ($sUids as $uid) {
+    $response .= processUid($uid);
+}
+
+echo $response;
 
 
-if ($uid == "123") {        // test case for when steps aren't actually working
-    $imageURL = "images/icons/unknowntype.png";
-    $response = '<div class="displayStep" id="' . "123" . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';
-    echo $response;
-} 
-else if($uid == '456') {
-    $imageURL = "images/icons/unknowntype.png";
-    $response = '<div class="displayStep" id="' . "456" . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';
-    echo $response;
-}
-else {
-    
-
-    if ($uid == "divider") {    //a divider has been requested instead of a displaystep
-        $response = '<div class="divider"></div>';
-        echo $response;
-    } else {        // an actual step has been requested.
+/*
+ * ProcessUid needs to be changed once all the object classes are fixed. The '123', '456' test cases are not functional and are for testing puroses only.
+ * Additional onclick events for selecting objects would need to be added as well.
+ */
 
 
-        $dbi = new DatabaseInterface();
+
+function processUid($uid) {
+    if ($uid == "123") {        // test case for when steps aren't actually working
+        $imageURL = "images/icons/unknowntype.png";
+        $responsePart = '<div class="displayStep" id="' . "123" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';
+        return $responsePart;
+    } else if ($uid == '456') {
+        $imageURL = "images/icons/unknowntype.png";
+        $responsePart = '<div class="displayStep" id="' . "456" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';
+        return $responsePart;
+    } else {
+
+
+        if ($uid == "divider") {    //a divider has been requested instead of a displaystep
+            $responsePart = '<div class="divider"></div>';
+            return $responsePart;
+        } else {        // an actual step has been requested.
+            
 //Check in order: survey, application, dashboard.
-        $result = null;
-        $resultType = null;
-        $surveys = $dbi->get("Survey", array("uid" => $uid));
-        if (count($surveys) > 0) {
-            if ($surveys[0] != null) {
-                // A survey exists with the given UID!
-                $result = $surveys[0];
-                $resultType = "Survey";
-            }
-        }
-
-        if (result != null) {
-            $applications = $dbi->get("Application", array("uid" => $uid));
-            if (count($applications) > 0) {
-                if ($applications[0] != null) {
-                    // An application exists with the given UID!
-                    $result = $applications[0];
-                    $resultType = "Application";
+            $result = null;
+            $resultType = null;
+            $surveys = $dbi->get("Survey", array("uid" => $uid));
+            if (count($surveys) > 0) {
+                if ($surveys[0] != null) {
+                    // A survey exists with the given UID!
+                    $result = $surveys[0];
+                    $resultType = "Survey";
                 }
             }
-        }
 
-        if (result != null) {
-            $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
-            if (count($dashboards) > 0) {
-                if ($dashboards[0] != null) {
-                    // A dashboard exists with the given UID!
-                    $result = $dashboards[0];
-                    $resultType = "Dashboard";
+            if (result != null) {
+                $applications = $dbi->get("Application", array("uid" => $uid));
+                if (count($applications) > 0) {
+                    if ($applications[0] != null) {
+                        // An application exists with the given UID!
+                        $result = $applications[0];
+                        $resultType = "Application";
+                    }
                 }
             }
-        }
+
+            if (result != null) {
+                $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
+                if (count($dashboards) > 0) {
+                    if ($dashboards[0] != null) {
+                        // A dashboard exists with the given UID!
+                        $result = $dashboards[0];
+                        $resultType = "Dashboard";
+                    }
+                }
+            }
 
 // If result is still null at this point, the passed UID does not refer to an existing object!
-        if ($result == null || $resultType == null) {
-            echo "Non-existing UID passed!";
-        } else {
+            if ($result == null || $resultType == null) {
+                echo "Non-existing UID passed!";
+            } else {
 
-            // set relevant variables based on the type and properties of the step in question (currently stored in $result)
-            switch (strtolower($resultType)) {
-                case "questionnaire":
-                    $imageURL = "images/icons/questionnaire.png";
-                    break;
-                case "dashboard":
-                    $imageURL = "images/icons/dashboard.png";
-                    break;
-                case "application":
-                    $imageURL = "images/icons/application.png";
-                    break;
-                default:
-                    $imageURL = "images/icons/unknowntype.png";
-                    break;
-            }
+                // set relevant variables based on the type and properties of the step in question (currently stored in $result)
+                switch (strtolower($resultType)) {
+                    case "survey":
+                        $imageURL = "images/icons/survey.png";
+                        break;
+                    case "dashboard":
+                        $imageURL = "images/icons/dashboard.png";
+                        break;
+                    case "application":
+                        $imageURL = "images/icons/application.png";
+                        break;
+                    default:
+                        $imageURL = "images/icons/unknowntype.png";
+                        break;
+                }
 
 //echo out the HTML markup
-            $response = '<div class="displayStep" id="' . $result->uid . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
-            echo $response;
+                $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
+                return $responsePart;
+            }
         }
     }
 }
+
 ?>
