Index: Dev/trunk/js/sequencerScripts.js
===================================================================
--- Dev/trunk/js/sequencerScripts.js	(revision 168)
+++ Dev/trunk/js/sequencerScripts.js	(revision 169)
@@ -138,4 +138,45 @@
 }
 
+function deleteStep() {
+    // delete an object from the session.
+    // note: does not actually remove the object from the database, only takes it out of the pipeline array.
+        
+    var pl = stringToArray(document.getElementById("pipelineStringField").value, ",");
+    var plType = stringToArray(document.getElementById("pipelineTypeField").value, ",");
+    var plUpdated = stringToArray(document.getElementById("pipelineUpdatedField").value, ",");
+    var selectedStep = document.getElementById("selectedStepField").value;
+    
+    // if no step has been selected, exit the function
+    if (selectedStep == undefined || selectedStep == "") {
+        return;
+    }
+    
+    // find the array index of the specified object uid, then remove it from all three arrays.
+    var index = pl.indexOf(selectedStep);
+    if (index >= 0 && index < pl.length) {
+        pl.splice(index, 1);
+        plType.splice(index, 1);
+        plUpdated.splice(index, 1);
+        // set the updated status of all objects from *index* and forward to "0" (out of date)
+        // this way they will be refreshed the next time updateSequencer(); is called, adn the visual display will match the new pipeline.
+        for (var i = index-1; i < plUpdated.length; i++) {
+            if (i >= 0 ) {
+                plUpdated[i] = "0";
+            }
+        }
+    }
+    
+    document.getElementById("pipelineStringField").value = arrayToString(pl, ",");
+    document.getElementById("pipelineTypeField").value = arrayToString(plType, ",");
+    document.getElementById("pipelineUpdatedField").value = arrayToString(plUpdated, ",");
+    deselectStep(selectedStep);     // Make sure the info panel is up to date as well. (Not showing anything, as it should be...)
+    document.getElementById("numSteps").value--;
+    
+    updateSequencer(false);
+    
+    
+    
+}
+
 function deselectStep(uid) {
     var field = document.getElementById("selectedStepField");
@@ -225,4 +266,5 @@
 function updateSequencer(firstLoad) {
     // Load hidden field values
+    
     var plString = document.getElementById("pipelineStringField").value;
     var plTypeString = document.getElementById("pipelineTypeField").value;
@@ -231,12 +273,14 @@
     
     if (count < 1) {
+        document.getElementById("seqContentWrapper").innerHTML = "";
         return;
     }
     // If this is on page-load time
     if (firstLoad == true) {
+        var seqContent = document.getElementById("seqContentWrapper");
+        seqContent.innerHTML = "";
         requestString = plString.slice(0, -1);
         requestString = requestString.replace(/,/g, ",divider,");
         newAjaxRequest("uids="+requestString, "returnStep.php", function(result) {
-            var seqContent = document.getElementById("seqContentWrapper");
             seqContent.innerHTML = result.responseText;
         }, true);
@@ -258,5 +302,9 @@
         document.getElementById("numSteps").value = count;
         var seqContent = document.getElementById("seqContentWrapper");
-        if (seqContent.childNodes.length > (2*count)-1) {
+        // hier zit een fout. Als er een deleted step nog in de pipeline staat haalt hij de eerste valid step weg ipv een text node.
+        // twee mogelijkheden: 
+        // 1: check of het text node is.
+        // 2: modulo check of het een even aantal steps is. Als alles klopt kan er onmogelijk een even aantal childNodes zijn.
+        if (seqContent.childNodes.length % 2 == 0 && seqContent.childNodes.length > 0) {
             seqContent.removeChild(seqContent.childNodes[0]);
             
@@ -320,4 +368,20 @@
                 //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!");
                 //alert(timeDiff.getDiff());
+                
+                // If seqContent contains any further entries when the last pipeline uid has been drawn, these are to be removed.
+                // This happens after the user performs a "delete step" operation and there is now one fewer step in the array than in seqContent.
+                // All steps other than the first and the last are auto-adjusted due to "out of date" flag.
+                if (i >= pl.length - 1) {
+                    
+                    // This is a really complicated way of saying "Delete the next two elements if they exist"
+                    while ((nextElement = newDiv.nextSibling) != undefined) {
+                        seqContent.removeChild(nextElement);
+                    }
+                    
+                }
+                // Do the same check for the first step in the pipeline. 
+                // Is there no more elegant solution for this? For instance, check if a step should be in the pipeline in the first place, else delete it and it's following divider
+                
+                
                 updateDividers(newDiv);
             }
