Index: Dev/trunk/classes/SessionCreationTool.php
===================================================================
--- Dev/trunk/classes/SessionCreationTool.php	(revision 91)
+++ Dev/trunk/classes/SessionCreationTool.php	(revision 93)
@@ -20,5 +20,4 @@
         var_dump($_POST);
         var_dump($session);
-        
         ?>
 
@@ -49,41 +48,48 @@
         <script type="text/javascript">
             var pipelineCount = 0;
-                                                                                                                                                                                                                                                                                                                                     
+                                                                                                                                                                                                                                                                                                                                             
             // =============================================================
-                                                                                                                                                                                                                                                                                                                                                            
-            function addSurvey(surveyID) {       
+                                                                                                                                                                                                                                                                                                                                                                    
+            function addSurvey() {     
                 var surveysList = document.getElementById("surveysList");
-                            
-                if(surveysList.selectedIndex != -1 || surveyID != null)
+                var entryType = "s";
+                var color = "#00ccff";
+                
+                addFromList(surveysList, entryType, color);
+            }
+                    
+            function addApplication()
+            {
+                var applicationsList = document.getElementById("applicationsList");
+                var entryType = "a";
+                var color = "gold";
+                
+                addFromList(applicationsList, entryType, color);
+            }
+                    
+            function addFromList(list, entryType, color)
+            {
+                if(list.selectedIndex != -1)
                 {
                     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";
-                                                                                                                                                                                                                                                
+                    
+                    pipelineCount++;
+                    
+                    entry.setAttribute("value", list.options[list.selectedIndex].value);
+                    entry.innerHTML = pipelineCount + ". " + list.options[list.selectedIndex].innerHTML;
+                    
+                    entry.style.backgroundColor = color;
+                    entry.name = pipelineCount + entryType;
+                    entry.entryType = entryType;
+                    
                     pipeline.appendChild(entry);
-                }                         
-            }
-                                                                                                                                                                                                                                    
+                }
+            }
+                                                                                                                                                                                                                                            
             function addDashboard() {
                 pipelineCount++;
                 var pipeline = document.getElementById("pipeline");
-                                                                                                                                                                                                                                        
+                                                                                                                                                                                                                                                
                 var entry = document.createElement("option");
                 entry.setAttribute("value", "dashboard");
@@ -93,8 +99,8 @@
                 entry.name = pipelineCount + "d";
                 entry.entryType = "d";
-                                                                                                                                                                                                                                        
+                                                                                                                                                                                                                                                
                 pipeline.appendChild(entry);
             }
-                                                                                    
+                                                                                            
             function removeFromPipeline() {
                 var pipeline = document.getElementById("pipeline");
@@ -103,9 +109,10 @@
                     var index = pipeline.selectedIndex;
                     pipeline.remove(index);
-                    if (pipelineCount > 1)
+                    if (pipelineCount > 1 && 
+                        pipeline.options[index] != null)
                     {
                         pipeline.options[index].selected = true;
                     }
-                                                                           
+                                                                                   
                     for(var i = index; i < pipeline.length; i++)
                     {
@@ -119,12 +126,12 @@
                 }
             }
-                                                                                                                                                                                                                                                     
+                                                                                                                                                                                                                                                             
             function submitPipeline()
             {
                 var form = document.getElementById("sessionCreationForm");
-                                                                                                                                                                                                                        
+                                                                                                                                                                                                                                
                 var pipeline = document.getElementById("pipeline").options;
-                                                                                                                                                                                                                               
-                                                                                                                                                                                                                                
+                                                                                                                                                                                                                                       
+                                                                                                                                                                                                                                        
                 for (var i = 0; i < pipeline.length; i++)
                 {
@@ -133,13 +140,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);
             }
@@ -250,5 +257,5 @@
     private function addApplicationToPipelineButton() {
         ?>
-        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" />
+        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" onclick="addApplication()"/>
         <?php
     }
