Index: Dev/trunk/js/sequencerScripts.js
===================================================================
--- Dev/trunk/js/sequencerScripts.js	(revision 154)
+++ Dev/trunk/js/sequencerScripts.js	(revision 164)
@@ -56,5 +56,10 @@
         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");
+                if (hasClass(nodes[i], "selected")) {
+                    removeClass(nodes[i], "selected");
+                }
+                else {
+                    addClass(nodes[i], "selected");
+                }                
             }
             else {
@@ -88,5 +93,5 @@
  */
 
-function newAjaxRequest(c, u, cb) {
+function newAjaxRequest(c, u, cb, async) {
     
     var xml;
@@ -101,11 +106,11 @@
     // subscribe the callback function to a response event
     xml.onreadystatechange = function() {
+        xml.responseText = "Processing...";
         if (xml.readyState == 4 && xml.status == 200) {
-            //alert("Received!");
             cb(xml);
         }
     };
     // initialize XMLRequest
-    xml.open("POST", u, true);
+    xml.open("POST", u, async);
     xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     var contentString = "";
@@ -138,5 +143,5 @@
     newAjaxRequest(c, u, function(result) {
         document.getElementById("seqContent").innerHTML = result.responseText;
-    });
+    }, true);
 }
 
@@ -147,12 +152,6 @@
     newAjaxRequest(c, u, function(result) {
         el.innerHTML = result.responseText;
-    });
-}
-                            
-
-
-
-
-
+    }, true);
+}
 
 function drawSteps() {
@@ -163,5 +162,110 @@
 }
 
-function updatePipelineHidden (pipelineString) {
-    
-}
+function updateSequencer() {
+    var plString = document.getElementById("pipelineStringField").value;
+    var plTypeString = document.getElementById("pipelineTypeField").value;
+    var plUpdatedString = document.getElementById("pipelineUpdatedField").value;
+        
+    var pl = plString.split(",");
+    var plType = plTypeString.split(",");
+    var plUpdated = plUpdatedString.split(",");
+    //console.log(plUpdated);
+    
+    
+    for (var i = 0; i < pl.length; i++) {   // loop through pipeline contents
+        if (plUpdated[i] == "0") {   // if the element is not up to date
+            // first remove the step representation from the sequencer
+            var seqContent = document.getElementById("seqContent");
+            var element = document.getElementById(pl[i]);
+            var nextElement = element.nextSibling;
+            
+            // now request a new step representation and insert it after previousElement
+            var holderDiv = document.createElement("div");
+            var requestString = "uids="+pl[i];
+            var resultText;
+            newAjaxRequest(requestString, "returnStep.php", function(result) {
+                holderDiv.innerHTML = result.responseText; 
+            }, false);
+            
+            //debugger;
+            while (holderDiv.childNodes.length == 1) {
+            // wait for response
+            }
+            var newDiv = holderDiv.childNodes[1];
+            seqContent.replaceChild(newDiv, element);
+            plUpdated[i] = "1";
+        // ALTERNATIVE METHOD TO REPLACECHILD!!!
+        //seqContent.removeChild(element);
+        //seqContent.insertBefore(newDiv, nextElement);
+            
+            
+        }
+        else {
+            
+    }
+    }
+    
+    // afterwards, convert the arrays back to strings
+    var newUpdatedString = "";
+    
+    for (var i = 0; i < plUpdated.length; i++) {
+        newUpdatedString += plUpdated[i]+",";
+    }
+    
+    if (newUpdatedString.substring(newUpdatedString.length - 1) == ",") {   // remove comma at the end of string!
+        newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1);
+        
+    }
+    document.getElementById("pipelineUpdatedField").value = newUpdatedString;
+    
+}
+
+function savePipeline() {
+    var answer = confirm("Save changes to pipeline?");
+    if (answer) {
+        newAjaxRequest("", "savesession.php", function(){}, false);
+        alert("Saved!");
+    }
+}
+
+function t_setOutOfDate() {
+    // if a step is currently selected
+    var uid = document.getElementById("selectedStepField").value;
+    if (uid == "") {
+        alert("No step selected!");
+        return;
+    }
+    
+    // convert to arrays for looping
+    var plString = document.getElementById("pipelineStringField").value;
+    var plTypeString = document.getElementById("pipelineTypeField").value;
+    var plUpdatedString = document.getElementById("pipelineUpdatedField").value;
+    
+    var pl = plString.split(",");
+    var plType = plTypeString.split(",");
+    var plUpdated = plUpdatedString.split(",");
+    
+    
+    
+    // set the targeted element's tag for "Needs updating"
+    for (var i = 0; i < pl.length; i++) {
+        if (pl[i] == uid) {
+            plUpdated[i] = 0;
+        }
+    }
+    
+    // then rewrite the content strings and set them to the appropriate fields
+    
+    var newUpdatedString = "";
+    for (var i = 0; i < pl.length; i++) {
+        newUpdatedString += plUpdated[i]+",";
+    }
+    alert(newUpdatedString+": OLD");
+    if (newUpdatedString.substring(newUpdatedString.length-1) == ",") {
+        newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1);
+    }
+    alert(newUpdatedString+": NEW!");
+    
+    document.getElementById("pipelineUpdatedField").value = newUpdatedString;
+//alert("OOD set");
+}
