Index: Dev/trunk/classes/SurveyCreationTool.php
===================================================================
--- Dev/trunk/classes/SurveyCreationTool.php	(revision 11)
+++ Dev/trunk/classes/SurveyCreationTool.php	(revision 17)
@@ -12,4 +12,5 @@
         SurveyCreationTool::javascript();
         ?>
+
         <div id="surveyCreation"><form action="submitsurvey.php" method="post">
                 <?php
@@ -17,4 +18,5 @@
                 SurveyCreationTool::descriptionBox();
                 SurveyCreationTool::questionCreationForm();
+                SurveyCreationTool::addQuestionButton();
                 SurveyCreationTool::submitButton();
                 ?></form></div>
@@ -25,5 +27,34 @@
         ?>
         <script type="text/javascript">
-                                                                                    
+            var questionCount = 1;           
+                                                                            
+            function getNewQuestion()
+            {
+                var questionDiv = document.createElement("div");
+                var htmlStr = 
+                    "<div id='question" + questionCount + "' class='question'>" +
+                    "<table class='questionTable'>" +
+                    "<th>Question " + questionCount + "</th>" +
+                    "<tr><td><label for='questionTitle'>Title</label></td>" + 
+                    "<td><input type='text' class='questionTitle' name='questionTitle" + questionCount + "' size='30' value='Untitled Question' /></td></tr>" +
+                    "<tr><td><label for='questionDescription'>Description</label></td>" + 
+                    "<td><input type='text' class='questionDescription' name='questionDescription" + questionCount + "' size='60' value='Write a question description here.' /></td>" +
+                    "<tr><td><label for='questionType'>Answer type</label></td>" + 
+                    "<td><select id='" + questionCount + "' name='questionType" + questionCount + "' onchange='handleType(this)'><br />"+
+                    "<option value='text' selected='selected'>Text</option>" +
+                    "<option value='multipleChoice'>Multiple choice</option>" +
+                    "<option value='checkboxes'>Checkboxes</option>" +
+                    "<option value='scale'>Scale</option>" +
+                    "<option value='grid'>Grid</option>" +
+                    "</select></td></tr>" +
+                    "</table>" +
+                    "<div id='answersDiv" + questionCount + "'></div>" +
+                    "</div>";
+                                                                        
+                questionDiv.innerHTML = htmlStr;
+                                                                        
+                return questionDiv;
+            }
+                                                                            
             function handleFocus(input)
             {
@@ -35,15 +66,92 @@
                 }
             }
-            
+                                                                                                            
             function handleBlur(input)
-            {
+            {        
+                var surveyTitle = document.getElementById('surveyTitle');
+                var surveyDescription = document.getElementById('surveyDescription');
+                                                                                            
                 if (input.value == "")
                 {
                     input.style.color = "gray";
-                    input.value = "Untitled Survey";
                     input.clicked = null;
+                                                                                                                    
+                    if (input == surveyTitle)
+                    {
+                        input.value = "Untitled Survey";
+                    }
+                    else if (input == surveyDescription)
+                    {
+                        input.value = "Write a helpful description for this survey here.";
+                    }
+                }                           
+            }
+                                                            
+            function handleType(select)
+            {
+                var type = select.valueOf().value;
+                var answersDiv = document.getElementById("answersDiv" +  select.id);
+                answersDiv.answerCount = 1;
+                answersDiv.clicked = null;
+                
+                switch (type) {
+                    case 'multipleChoice':
+                        answersDiv.innerHTML = "";
+                        addOption(select.id);
+                                                
+                        break;
+                    case 'text':
+                        answersDiv.innerHTML = "";
+                        
+                        break;
+                    case 'checkboxes':
+                        answersDiv.innerHTML = "";                                                
+                        break;
+                    case 'scale':
+                        answersDiv.innerHTML = "";                                                
+                        break;
+                    case 'grid':
+                        answersDiv.innerHTML = "";                                                
+                        break;
+                    default:
+                        break;
                 }
+
             }
-                                                                                    
+                                            
+                                    
+            function addOption(questionNumber)
+            {        
+                var answersDiv = document.getElementById("answersDiv" + questionNumber);
+                var answerCount = answersDiv.answerCount;
+                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' />";
+                    answersDiv.clicked = true;
+                }
+                                               
+                answerDiv.innerHTML = htmlStr;
+                                               
+                answersDiv.appendChild(answerDiv);
+                answersDiv.answerCount++;
+            }
+                                            
+                                                         
+            function addQuestion()
+            {
+                var questionsDiv = document.getElementById('questionsDiv');
+                var newQuestion = getNewQuestion();
+                                                                        
+                questionsDiv.appendChild(newQuestion);
+                questionCount++;
+            }
+                                                                                                                                                                                    
         </script>
         <?php
@@ -52,5 +160,5 @@
     private static function titleBox() {
         ?>
-        <input type="text" name="surveyTitle" value="Untitled Survey" id="surveyTitle" size="30" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
+        <input type="text" id="surveyTitle" name="surveyTitle" value="Untitled Survey" size="30" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
         <?php
     }
@@ -58,15 +166,20 @@
     private static function descriptionBox() {
         ?>
-        <textarea id="surveyDescription" rows="3" cols="80" name="surveyDescription">Write a helpful description for this survey here.</textarea>
+        <textarea id="surveyDescription" rows="3" cols="80" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)">Write a helpful description for this survey here.</textarea>
         <?php
     }
 
     private static function questionCreationForm() {
-
-        SurveyCreationTool::addQuestionButton();
+        ?>
+        <div id='questionsDiv'>
+        </div>
+        <script type="text/javascript"> addQuestion(); </script>
+        <?php
     }
 
     private static function addQuestionButton() {
-        
+        ?>
+        <input id="addQuestionButton" type="button" onclick="addQuestion()" value="Add New Question" class="surveyButton" />
+        <?php
     }
 
@@ -74,5 +187,5 @@
         ?>
         <input type="submit" name="submitSurvey" 
-               value="Submit Survey!" id="submitSurvey"/>
+               value="Submit Survey!" class="surveyButton" id="submitSurvey"/>
         <?php
     }
