Index: Dev/trunk/classes/SessionCreationTool.php
===================================================================
--- Dev/trunk/classes/SessionCreationTool.php	(revision 69)
+++ Dev/trunk/classes/SessionCreationTool.php	(revision 70)
@@ -17,6 +17,7 @@
 
         $this->javascript();
+        var_dump($_POST);
         var_dump($session);
-        var_dump($_POST);
+        
         ?>
 
@@ -46,38 +47,41 @@
         <script type="text/javascript">
             var pipelineCount = 0;
-                                                                                                                                                                                                                                                                             
+                                                                                                                                                                                                                                                                                                                                     
             // =============================================================
-                                                                                                                                                                                                                                                                                                    
-            function addSurvey(surveyID) {
-                pipelineCount++;
-                                                                                                                                                                        
-                var pipeline = document.getElementById("pipeline");
+                                                                                                                                                                                                                                                                                                                                                            
+            function addSurvey(surveyID) {       
                 var surveysList = document.getElementById("surveysList");
-                                                                                                                                                                                                
-                var entry = document.createElement("option");
-                                                                                                                                        
-                if (surveyID != null)
+                            
+                if(surveysList.selectedIndex != -1 || surveyID != null)
                 {
-                    entry.setAttribute("value", surveyID);
-                    entry.innerHTML = pipelineCount + ". " + surveysList.options.namedItem(surveyID).innerHTML;
-                }
-                else
-                {
-                    entry.setAttribute("value", surveysList.options[surveysList.selectedIndex].value);
-                                                                                                                                    
-                    entry.innerHTML = pipelineCount + ". " + surveysList.options[surveysList.selectedIndex].innerHTML;
-                                                                                                                                    
-                }
-                entry.style.backgroundColor = "#0090ac";
-                entry.name = pipelineCount + "s";
-                entry.entryType = "s";
-                                                                                                                                                                                        
-                pipeline.appendChild(entry);
-            }
-                                                                                                                                                                            
+                    var pipeline = document.getElementById("pipeline");
+                    var entry = document.createElement("option");
+                            
+                    if (surveyID != null)
+                    {
+                        pipelineCount++;
+                        entry.setAttribute("value", surveyID);
+                        entry.innerHTML = pipelineCount + ". " + surveysList.options.namedItem(surveyID).innerHTML;
+                    }
+                    else if(surveysList.selectedIndex != -1)
+                    {
+                        pipelineCount++;
+                        entry.setAttribute("value", surveysList.options[surveysList.selectedIndex].value);
+                                                                                                                                                                                            
+                        entry.innerHTML = pipelineCount + ". " + surveysList.options[surveysList.selectedIndex].innerHTML;
+                                                                                                                                                                                            
+                    }
+                    entry.style.backgroundColor = "#0090ac";
+                    entry.name = pipelineCount + "s";
+                    entry.entryType = "s";
+                                                                                                                                                                                                                                                
+                    pipeline.appendChild(entry);
+                }                         
+            }
+                                                                                                                                                                                                                                    
             function addDashboard() {
                 pipelineCount++;
                 var pipeline = document.getElementById("pipeline");
-                                                                                                                                                                                
+                                                                                                                                                                                                                                        
                 var entry = document.createElement("option");
                 entry.setAttribute("value", "dashboard");
@@ -87,34 +91,38 @@
                 entry.name = pipelineCount + "d";
                 entry.entryType = "d";
-                                                                                                                                                                                
+                                                                                                                                                                                                                                        
                 pipeline.appendChild(entry);
             }
-                            
+                                                                                    
             function removeFromPipeline() {
                 var pipeline = document.getElementById("pipeline");
-                if (pipeline.selectedIndex != null)
+                if (pipeline.selectedIndex != -1)
                 {
                     var index = pipeline.selectedIndex;
                     pipeline.remove(index);
-                   
+                    if (pipelineCount > 1)
+                    {
+                        pipeline.options[index].selected = true;
+                    }
+                                                                           
                     for(var i = index; i < pipeline.length; i++)
-                        {
-                            var entry = pipeline.options[i];
-                            entry.name = "" + (i+1) + entry.entryType;
-                            var htmlStr = entry.innerHTML;
-                            var dotIndex = htmlStr.indexOf('.');
-                            entry.innerHTML = (i+1) + htmlStr.substr(dotIndex);
-                        }
+                    {
+                        var entry = pipeline.options[i];
+                        entry.name = "" + (i+1) + entry.entryType;
+                        var htmlStr = entry.innerHTML;
+                        var dotIndex = htmlStr.indexOf('.');
+                        entry.innerHTML = (i+1) + htmlStr.substr(dotIndex);
+                    }
                     pipelineCount--;
                 }
             }
-                                                                                                                                                                                             
+                                                                                                                                                                                                                                                     
             function submitPipeline()
             {
                 var form = document.getElementById("sessionCreationForm");
-                                                                                                                                                                
+                                                                                                                                                                                                                        
                 var pipeline = document.getElementById("pipeline").options;
-                                                                                                                                                                       
-                                                                                                                                                                        
+                                                                                                                                                                                                                               
+                                                                                                                                                                                                                                
                 for (var i = 0; i < pipeline.length; i++)
                 {
@@ -123,13 +131,13 @@
                     pipelineElem.value = pipeline[i].value;
                     pipelineElem.type = "hidden";
-                                                                                                                                                                    
+                                                                                                                                                                                                                            
                     form.appendChild(pipelineElem);
                 }
-                                                                                                                                                        
+                                                                                                                                                                                                                
                 var count = document.createElement("input");
                 count.name = "pipelineCount";
                 count.value = pipelineCount;
                 count.type = "hidden";
-                                                                                                                                                        
+                                                                                                                                                                                                                
                 form.appendChild(count);
             }
