Index: Dev/trunk/classes/SurveyCreationTool.php
===================================================================
--- Dev/trunk/classes/SurveyCreationTool.php	(revision 19)
+++ Dev/trunk/classes/SurveyCreationTool.php	(revision 20)
@@ -29,5 +29,5 @@
         <script type="text/javascript">
             var questionCount = 1;           
-                                                                                                            
+                                                                                                                    
             function getNewQuestion()
             {
@@ -52,10 +52,10 @@
                     "<div id='answersDiv" + questionCount + "'></div>" +
                     "</div>";
-                                                                                                        
+                                                                                                                
                 questionDiv.innerHTML = htmlStr;
-                                                                                                        
+                                                                                                                
                 return questionDiv;
             }
-                                                                                                            
+                                                                                                                    
             function handleFocus(input)
             {
@@ -67,15 +67,15 @@
                 }
             }
-                                                                                                                                            
+                                                                                                                                                    
             function handleBlur(input)
             {        
                 var surveyTitle = document.getElementById('surveyTitle');
                 var surveyDescription = document.getElementById('surveyDescription');
-                                                                                                                            
+                                                                                                                                    
                 if (input.value == "")
                 {
                     input.style.color = "gray";
                     input.clicked = null;
-                                                                                                                                                    
+                                                                                                                                                            
                     if (input == surveyTitle)
                     {
@@ -88,5 +88,5 @@
                 }                           
             }
-                                                                                            
+                                                                                                    
             function handleType(select)
             {
@@ -95,10 +95,10 @@
                 answersDiv.answerCount = 1;
                 answersDiv.clicked = null;
-                                                
+                                                        
                 switch (type) {
                     case 'mc':
                         answersDiv.innerHTML = "";
                         addOption(select.id);
-                                                                                
+                                                                                        
                         break;
                     case 'text':
@@ -124,6 +124,6 @@
 
             }
+                                                                                    
                                                                             
-                                                                    
             function addOption(questionNumber)
             {        
@@ -132,51 +132,68 @@
                 var answerDiv = document.createElement("div");
                 answerDiv.className = "answerDiv";
-                                                                        
+                                                                                
                 var htmlStr = "<input type='text' name='q" + 
                     questionNumber + "ans" + answerCount + "' value='Option " + answerCount + "' />";
-                                                
+                                                        
                 if (answersDiv.clicked == null)
                 {
                     htmlStr += "<input type='button' id='addOpt'"
-                        + " class='surveyButton' onclick='addOption(" + questionNumber + ")' value='Add Option' />";
+                        + " class='surveyButton' onclick='addOption(" + questionNumber + ")' value='Add Option' />" +
+                        "<input type='button' class='surveyButton' onclick='removeOption(" + questionNumber + ")' value='x' />";
+                            
                     answersDiv.clicked = true;
                 }
-                                                                               
+                                                                                       
                 answerDiv.innerHTML = htmlStr;
-                                                                               
+                        
+                answerDiv.prev = answersDiv.lastAnswer; //singly linked list
+                answersDiv.lastAnswer = answerDiv;
+                                                                                       
                 answersDiv.appendChild(answerDiv);
                 answersDiv.answerCount++;
             }
-                                    
+                    
+            function removeOption(questionNumber)
+            {
+                var answersDiv = document.getElementById("answersDiv" + questionNumber);
+                       
+                if (answersDiv.lastAnswer.prev != null)
+                {
+                    answersDiv.removeChild(answersDiv.lastAnswer);
+                    answersDiv.lastAnswer = answersDiv.lastAnswer.prev;
+                    answersDiv.answerCount--;
+                }
+            }
+                                            
             function minMax(questionNumber)
             {
                 var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                       
+                                               
                 var answerDiv = document.createElement("div");
                 answerDiv.className = "answerDiv";
                 answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' name='min" + questionNumber + "' />" +
                     "<label for='max'>Max</label><input type='text' name='max" + questionNumber + "' />";
-                                   
+                                           
                 answersDiv.appendChild(answerDiv);
             }  
-                                    
+                                            
             function minMaxIncr(questionNumber)
             {
                 minMax(questionNumber);
                 var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                       
+                                               
                 var answerDiv = document.createElement("div");
                 answerDiv.className = "answerDiv";
                 answerDiv.innerHTML = "<label for='incr'>Increment by</label><input type='text' name='incr" + questionNumber + "' />";
-                                   
+                                           
                 answersDiv.appendChild(answerDiv);
             }         
-                                                                                         
                                                                                                  
+                                                                                                         
             function addQuestion()
             {
                 var questionsDiv = document.getElementById('questionsDiv');
                 var newQuestion = getNewQuestion();
-                                
+                                        
 
                 newQuestion.prev = document.lastQuestion;
@@ -186,9 +203,9 @@
                 questionCount++;
             }
-                            
+                                    
             function removeLastQuestion()
             {
                 var questionsDiv = document.getElementById('questionsDiv');
-                                
+                                        
                 if (document.lastQuestion.prev != null)
                 {
@@ -202,7 +219,7 @@
                 }               
             }
-                          
-                                    
-                                                                                                                                                                                                                    
+                                  
+                                            
+                                                                                                                                                                                                                            
         </script>
         <?php
