<?
	/*****
		* This form collects the survey information and saves
		* it in the database when the last page is completed.
		****/
	
	// get vars
  $data = $HTTP_POST_VARS;
  
  // define the path
  define('PATH', './');
  
  // load supporting classes
  require(PATH . 'core/conf.php');
  include(PATH . DIR_WS_CLASSES . 'SurveyManager.php');
  	
  // create a new instance of the SurveyManager class
  $surveyMan = new SurveyManager();
  
  /*
********************************************************

CONTROLLER

********************************************************/  

	// get the image button image pressed	
	if (isset($data['submit_name'])) {
		$data[$data['submit_name']] = 1;
	}

  // control routines
  if(isset($data['submit']) && $data['submit']) {
  	
  	switch ($data['page']) {
  		case 1:
  			// check for errors on page 1
  			if (checkErrors(1)) {
  				saveData();
  				displayPage(2);
  			} else {
  				displayPage(1);
  			}
  			break;
  	}
  	
  } elseif(isset($data['cancel']) && $data['cancel']) {
  	
  	// cancelled the form submission
  	header("Location: http://www.nassm.org/");
		exit();
		
  } else {
  	
  	// display the first page 
  	displayPage(1);
  
  }
  
	// standard template for all tools
	include ("template.php");
	
  
/*
********************************************************
displayPage

Display the form for entering the information.
********************************************************/

function displayPage($page)
{
	global $CONTENT, $message, $errors, $data, $firstField, $fee;
	
	
	switch ($page) {
		case 1:			
			$firstField = null;
			
			$hidden = "";
			
			break;
	}
	
	
	
	$CONTENT .= "
		<form name=\"request\" method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">
		<input type=\"hidden\" name=\"submit_name\" value=\"submit\" />
		<input type=\"hidden\" name=\"page\" value=\"" . unEscapeData($page) . "\">
	";

	define("TITLE", "");

	if ($page < 4) {
		define("INSTRUCTIONS", "We are seeking feedback from the users of the NASSM web site on ways in which the site can be improved to better suit our members as well as the general public. Please complete the following questions, the click the <em>Finish</em> button.");
	} else {
		define("INSTRUCTIONS", "");
	}
	
	$CONTENT .= "
	<table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" align=\"center\">";
	
	
	switch ($page) {
		case 1:
			
			// Membership Status
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">Membership Status</div>
				</td></tr>";
		
			$shaded = true;
			// 1. membership
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q1']) && $errors['q1']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">1. What is your current membership status?</span>
					</td>
				</tr>";
			
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\">
					<input type=\"radio\" name=\"q1\" value=\"1\" " . ((isset($data['q1']) && $data['q1'] == "1") ? " checked=\"checked\"" : "") . "/>professional member<br />
					<input type=\"radio\" name=\"q1\" value=\"2\" " . ((isset($data['q1']) && $data['q1'] == "2") ? " checked=\"checked\"" : "") . "/>student member<br />
					<input type=\"radio\" name=\"q1\" value=\"3\" " . ((isset($data['q1']) && $data['q1'] == "3") ? " checked=\"checked\"" : "") . "/>emeritus member<br />
					<input type=\"radio\" name=\"q1\" value=\"4\" " . ((isset($data['q1']) && $data['q1'] == "4") ? " checked=\"checked\"" : "") . "/>former member<br />
					<input type=\"radio\" name=\"q1\" value=\"5\" " . ((isset($data['q1']) && $data['q1'] == "5") ? " checked=\"checked\"" : "") . "/>not a member<br />
					</span></td>
				</tr>";
				
			// 2. length of membership
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q2']) && $errors['q2']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">2. How long have you been a member?</span>
					</td>
				</tr>";
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\">
					<input type=\"radio\" name=\"q2\" value=\"1\" " . ((isset($data['q2']) && $data['q2'] == "1") ? " checked=\"checked\"" : "") . "/>less than 1 year<br />
					<input type=\"radio\" name=\"q2\" value=\"2\" " . ((isset($data['q2']) && $data['q2'] == "2") ? " checked=\"checked\"" : "") . "/>1 to 5 years<br />
					<input type=\"radio\" name=\"q2\" value=\"3\" " . ((isset($data['q2']) && $data['q2'] == "3") ? " checked=\"checked\"" : "") . "/>6 to 10 years<br />
					<input type=\"radio\" name=\"q2\" value=\"4\" " . ((isset($data['q2']) && $data['q2'] == "4") ? " checked=\"checked\"" : "") . "/>11 years or more<br />
					<input type=\"radio\" name=\"q2\" value=\"5\" " . ((isset($data['q2']) && $data['q2'] == "5") ? " checked=\"checked\"" : "") . "/>not a member<br />
					</span></td>
				</tr>";
				
			// 3. frequency of access
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q3']) && $errors['q3']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">3. How often do you access the NASSM web site?</span>
					</td>
				</tr>";
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\">
					<input type=\"radio\" name=\"q3\" value=\"1\" " . ((isset($data['q3']) && $data['q3'] == "1") ? " checked=\"checked\"" : "") . "/>less than once per month<br />
					<input type=\"radio\" name=\"q3\" value=\"2\" " . ((isset($data['q3']) && $data['q3'] == "2") ? " checked=\"checked\"" : "") . "/>1 to 4 times per month<br />
					<input type=\"radio\" name=\"q3\" value=\"3\" " . ((isset($data['q3']) && $data['q3'] == "3") ? " checked=\"checked\"" : "") . "/>5 to 8 times per month<br />
					<input type=\"radio\" name=\"q3\" value=\"4\" " . ((isset($data['q3']) && $data['q3'] == "4") ? " checked=\"checked\"" : "") . "/>9 times or more per month<br />
					</span></td>
				</tr>";
				
			// 4. where accessed from
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q4']) && $errors['q4']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">4. Where do you access the NASSM site from?</span>
					</td>
				</tr>";
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\">
					<input type=\"radio\" name=\"q4\" value=\"1\" " . ((isset($data['q4']) && $data['q4'] == "1") ? " checked=\"checked\"" : "") . "/>work/school<br />
					<input type=\"radio\" name=\"q4\" value=\"2\" " . ((isset($data['q4']) && $data['q4'] == "2") ? " checked=\"checked\"" : "") . "/>home<br />
					<input type=\"radio\" name=\"q4\" value=\"3\" " . ((isset($data['q4']) && $data['q4'] == "3") ? " checked=\"checked\"" : "") . "/>both<br />
					</span></td>
				</tr>";
				
			
			// New Web Site
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">New Web Site</div>
				</td></tr>";
		
			// 5. new web site statements
			$CONTENT .= "
				<tr>
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q5']) && $errors['q5']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">5. Please rate whether you agree or disagree with the following statements:</span>
					</td>
				</tr>";
				
			DrawRadioAgree("q5a", "&nbsp;&nbsp; a) I like the design of the new web site.", 1, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q5b", "&nbsp;&nbsp; b) I find the organization of the information easy to understand.", 1, $data, $errors, $shaded,$CONTENT);
			
			DrawRadioAgree("q5c", "&nbsp;&nbsp; c) I find the member login easy to use.", 1, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q5d", "&nbsp;&nbsp; d) In general, I find the site easy to use.", 1, $data, $errors, $shaded, $CONTENT);
			
			
			// Web Site Information
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">Information on the Web Site</div>
				</td></tr>";
		
			// 6. web site information
			$CONTENT .= "
				<tr>
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q6']) && $errors['q6']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">6. Please rate how important you think the following information on the web site is:</span>
					</td>
				</tr>";
				
			DrawRadioAgree("q6a", "&nbsp;&nbsp; a) Information about the NASSM conference", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6b", "&nbsp;&nbsp; b) Information about the Journal of Sport Management", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6c", "&nbsp;&nbsp; c) General information about NASSM (purpose, history, executive council, etc.)", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6d", "&nbsp;&nbsp; d) Information about EASM and SMAANZ", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6e", "&nbsp;&nbsp; e) List of universities offering sport management programs", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6f", "&nbsp;&nbsp; f) Newsletter and ListServ information", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6g", "&nbsp;&nbsp; g) Resume Bank", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6h", "&nbsp;&nbsp; h) Professional Village", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6i", "&nbsp;&nbsp; i) Information about joining NASSM", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6j", "&nbsp;&nbsp; j) Information about renewing NASSM memberships", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6k", "&nbsp;&nbsp; k) News and press releases", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6l", "&nbsp;&nbsp; l) List of professional members", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6m", "&nbsp;&nbsp; m) List of student members", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6n", "&nbsp;&nbsp; n) Online elections and voting", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6o", "&nbsp;&nbsp; o) Member-only forums", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q6p", "&nbsp;&nbsp; p) Ability to search the site", 2, $data, $errors, $shaded, $CONTENT);
			
			
			// New Features
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">New Features of the Web Site</div>
				</td></tr>";
		
			// 7. web site information
			$CONTENT .= "
				<tr>
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q7']) && $errors['q7']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">7. Please rate how important you think the following features for the web site would be if they were made available to you (note that some of these features have been part of the conference web site in the past):</span>
					</td>
				</tr>";
				
			DrawRadioAgree("q7a", "&nbsp;&nbsp; a) Online membership sign-up and renewal", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7b", "&nbsp;&nbsp; b) Online conference registration", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7c", "&nbsp;&nbsp; c) Online conference registration integrated with membership renewal", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7d", "&nbsp;&nbsp; d) Online conference abstracts for current conference", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7e", "&nbsp;&nbsp; e) Online conference abstracts for past conferences", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7f", "&nbsp;&nbsp; f) Online document archive (meeting minutes, constitutional documents, etc.)", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7g", "&nbsp;&nbsp; g) Rebuild and improve the Resume Bank", 2, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q7h", "&nbsp;&nbsp; h) Rebuild and improve the Professional Village", 2, $data, $errors, $shaded, $CONTENT);
			
			
				
			// General Questions
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">General Questions About the Web Site</div>
				</td></tr>";
				
			// 8. like best
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q8']) && $errors['q8']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">8. What aspects of the NASSM web site do you like the best? Why?</span>
					</td>
				</tr>";
			
			if (isset($data['q8'])) {
				$data_value = unEscapeData($data['q8']);
			} else {
				$data_value = "";
			}
			
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\"><textarea cols=\"80\" rows=\"8\" name=\"q8\">".$data_value."</textarea></span></td>
				</tr>";
				
			// 9. dislike
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q9']) && $errors['q9']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">9. What aspects of the NASSM web site do you dislike the most? Why?</span>
					</td>
				</tr>";
			
			if (isset($data['q9'])) {
				$data_value = unEscapeData($data['q9']);
			} else {
				$data_value = "";
			}
			
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\"><textarea cols=\"80\" rows=\"8\" name=\"q9\">".$data_value."</textarea></span></td>
				</tr>";
			
			// 10. difficulties
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q10']) && $errors['q10']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">10. Have you ever had any difficulties accessing information or using the web site since it has been re-designed? If so, please describe what happened.</span>
					</td>
				</tr>";
			
			if (isset($data['q10'])) {
				$data_value = unEscapeData($data['q10']);
			} else {
				$data_value = "";
			}
			
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\"><textarea cols=\"80\" rows=\"8\" name=\"q10\">".$data_value."</textarea></span></td>
				</tr>";
				
			// 11. new ideas
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q11']) && $errors['q11']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">11. Do you have any ideas for new content or features you would like to see on the NASSM web site? Please describe them.</span>
					</td>
				</tr>";
			
			if (isset($data['q11'])) {
				$data_value = unEscapeData($data['q11']);
			} else {
				$data_value = "";
			}
			
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\"><textarea cols=\"80\" rows=\"8\" name=\"q11\">".$data_value."</textarea></span></td>
				</tr>";
				
			// Business Office
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">Business Office Operations</div>
				</td></tr>";
				
			// 12. frequency of access of business office
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q12']) && $errors['q12']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">12. How often do you contact the NASSM Business Office?</span>
					</td>
				</tr>";
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\">
					<input type=\"radio\" name=\"q12\" value=\"1\" " . ((isset($data['q12']) && $data['q12'] == "1") ? " checked=\"checked\"" : "") . "/>less than once per year<br />
					<input type=\"radio\" name=\"q12\" value=\"2\" " . ((isset($data['q12']) && $data['q12'] == "2") ? " checked=\"checked\"" : "") . "/>1 to 4 times per year<br />
					<input type=\"radio\" name=\"q12\" value=\"3\" " . ((isset($data['q12']) && $data['q12'] == "3") ? " checked=\"checked\"" : "") . "/>5 to 8 times per year<br />
					<input type=\"radio\" name=\"q12\" value=\"4\" " . ((isset($data['q12']) && $data['q12'] == "4") ? " checked=\"checked\"" : "") . "/>9 times or more per year<br />
					</span></td>
				</tr>";	
			
			// 13. business office statements
			$CONTENT .= "
				<tr".displayShaded(!$shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q13']) && $errors['q13']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">13. Please rate whether you agree or disagree with the following statements:</span>
					</td>
				</tr>";
				
			DrawRadioAgree("q13a", "&nbsp;&nbsp; a) The Business Office staff are friendly and professional.", 1, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q13b", "&nbsp;&nbsp; b) The Business Office is well organized.", 1, $data, $errors, $shaded,$CONTENT);
			
			DrawRadioAgree("q13c", "&nbsp;&nbsp; c) Membership problems have been handled by the Business Office in a timely fashion.", 1, $data, $errors, $shaded, $CONTENT);
			
			DrawRadioAgree("q13d", "&nbsp;&nbsp; d) In general, I find the Business Office easy to work with.", 1, $data, $errors, $shaded, $CONTENT);
			
			// 14. difficulties
			$CONTENT .= "
				<tr".toggleShaded($shaded).">
					<td width=\"5%\" valign=\"top\">";
			if (isset($errors['q14']) && $errors['q14']) { 
				$CONTENT .= "<div align=\"right\"><span class=\"error_indicator\"><b>!</b></span></div>";
			} else {
				$CONTENT .= "&nbsp;";
			}
			$CONTENT .= "
					</td>
					<td colspan=\"2\"><span class=\"form_label\">14. Have you ever had any difficulties accessing information from the Business Office? If so, please describe what happened.</span>
					</td>
				</tr>";
			
			if (isset($data['q14'])) {
				$data_value = unEscapeData($data['q14']);
			} else {
				$data_value = "";
			}
			
			$CONTENT .= "
				<tr".displayShaded($shaded).">
					<td width=\"5%\">&nbsp;</td>
					<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
					<td width=\"85%\" valign=\"top\"><span class=\"form_field\"><textarea cols=\"80\" rows=\"8\" name=\"q14\">".$data_value."</textarea></span></td>
				</tr>";
			break;
			
		case 2:
			
			// Survey Confirmation
			$CONTENT .= "
				<tr><td colspan=\"3\">
				<div class=\"section\">Survey Confirmation</div>
				</td></tr>";
				
			
			$CONTENT .= "
				<tr>
					<td width=\"5%\" valign=\"top\"></td>
					<td colspan=\"2\" valign=\"top\"><span class=\"section_note\">
					Your survey information has been received. Thank you for your feedback about the NASSM web site.
					</span></td>
				</tr>";
				
			break;
			
	}
	
	if ($page < 2) {
 		//submit buttons
   	
  	$CONTENT .= "
  	<tr>
   		<td width=\"5%\" valign=\"top\">&nbsp;</td>
     	<td width=\"10%\">&nbsp;</td>
     	<td width=\"85%\" valign=\"top\"><br />";
    
    if ($page < 1) {
	    $CONTENT .= "
			<a href=\"javascript:setSubmit('submit');\">
			<input type=\"image\" src=\"images/buttons/next.gif\" alt=\"Submit\" name=\"Submit\" value=\"Submit\" /></a>&nbsp;&nbsp;";
  	} else {
  		$CONTENT .= "
			<a href=\"javascript:setSubmit('submit');\">
			<input type=\"image\" src=\"images/buttons/finish.gif\" alt=\"Submit\" name=\"Submit\" value=\"Submit\" /></a>&nbsp;&nbsp;";
  	}
   			
 		$CONTENT .= "
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 			<a href=\"javascript:setSubmit('cancel');\">
   		<img src=\"images/buttons/cancel.gif\" border=\"0\" alt=\"Cancel\" /></a>&nbsp;&nbsp;";
   		
  	$CONTENT .= "
   		</td>
   	</tr>";
  }
   	
  $CONTENT .= "
   	</table>
   	</form>";
}


/*
********************************************************
checkErrors

Check the errors in the form data.
********************************************************/

function checkErrors($page)
{
	global $errors, $data;
		
	switch ($page) {
		case 1:
			$error_count = 0;
			
			if (!isset($data['q1']) || !$data['q1']) {	
				$errors['q1'] = 'Please select an answer for question 1.';
				$error_count++;
			}
			if (!isset($data['q2']) || !$data['q2']) {	
				$errors['q2'] = 'Please select an answer for question 2.';
				$error_count++;
			}
			if (!isset($data['q3']) || !$data['q3']) {	
				$errors['q3'] = 'Please select an answer for question 4.';
				$error_count++;
			}
			if (!isset($data['q4']) || !$data['q4']) {	
				$errors['q4'] = 'Please select an answer for question 4.';
				$error_count++;
			}
			
			if (!isset($data['q5a']) || !$data['q5a']) {	
				$errors['q5a'] = 'Please select an answer for question 5a, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q5b']) || !$data['q5b']) {	
				$errors['q5b'] = 'Please select an answer for question 5b, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q5c']) || !$data['q5c']) {	
				$errors['q5c'] = 'Please select an answer for question 5c, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q5d']) || !$data['q5d']) {	
				$errors['q5d'] = 'Please select an answer for question 5d, or choose <em>no opinion</em>.';
				$error_count++;
			}
			
			if (!isset($data['q6a']) || !$data['q6a']) {	
				$errors['q6a'] = 'Please select an answer for question 6a, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6b']) || !$data['q6b']) {	
				$errors['q6b'] = 'Please select an answer for question 6b, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6c']) || !$data['q6c']) {	
				$errors['q6c'] = 'Please select an answer for question 6c, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6d']) || !$data['q6d']) {	
				$errors['q6d'] = 'Please select an answer for question 6d, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6e']) || !$data['q6e']) {	
				$errors['q6e'] = 'Please select an answer for question 6e, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6f']) || !$data['q6f']) {	
				$errors['q6f'] = 'Please select an answer for question 6f, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6g']) || !$data['q6g']) {	
				$errors['q6g'] = 'Please select an answer for question 6g, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6h']) || !$data['q6h']) {	
				$errors['q6h'] = 'Please select an answer for question 6h, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6i']) || !$data['q6i']) {	
				$errors['q6i'] = 'Please select an answer for question 6i, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6j']) || !$data['q6j']) {	
				$errors['q6j'] = 'Please select an answer for question 6j, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6k']) || !$data['q6k']) {	
				$errors['q6k'] = 'Please select an answer for question 6k, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6l']) || !$data['q6l']) {	
				$errors['q6l'] = 'Please select an answer for question 6l, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6m']) || !$data['q6m']) {	
				$errors['q6m'] = 'Please select an answer for question 6m, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6n']) || !$data['q6n']) {	
				$errors['q6n'] = 'Please select an answer for question 6n, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6o']) || !$data['q6o']) {	
				$errors['q6o'] = 'Please select an answer for question 6o, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q6p']) || !$data['q6p']) {	
				$errors['q6p'] = 'Please select an answer for question 6p, or choose <em>no opinion</em>.';
				$error_count++;
			}
			
			if (!isset($data['q7a']) || !$data['q7a']) {	
				$errors['q7a'] = 'Please select an answer for question 7a, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7b']) || !$data['q7b']) {	
				$errors['q7b'] = 'Please select an answer for question 7b, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7c']) || !$data['q7c']) {	
				$errors['q7c'] = 'Please select an answer for question 7c, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7d']) || !$data['q7d']) {	
				$errors['q7d'] = 'Please select an answer for question 7d, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7e']) || !$data['q7e']) {	
				$errors['q7e'] = 'Please select an answer for question 7e, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7f']) || !$data['q7f']) {	
				$errors['q7f'] = 'Please select an answer for question 7f, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7g']) || !$data['q7g']) {	
				$errors['q7g'] = 'Please select an answer for question 7g, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q7h']) || !$data['q7h']) {	
				$errors['q7h'] = 'Please select an answer for question 7h, or choose <em>no opinion</em>.';
				$error_count++;
			}
			
			if (!isset($data['q12']) || !$data['q12']) {	
				$errors['q12'] = 'Please select an answer for question 12.';
				$error_count++;
			}
			if (!isset($data['q13a']) || !$data['q13a']) {	
				$errors['q13a'] = 'Please select an answer for question 13a, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q13b']) || !$data['q13b']) {	
				$errors['q13b'] = 'Please select an answer for question 13b, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q13c']) || !$data['q13c']) {	
				$errors['q13c'] = 'Please select an answer for question 13c, or choose <em>no opinion</em>.';
				$error_count++;
			}
			if (!isset($data['q13d']) || !$data['q13d']) {	
				$errors['q13d'] = 'Please select an answer for question 13d, or choose <em>no opinion</em>.';
				$error_count++;
			}
			break;
			
	}
	
	if ($error_count > 0) {
		return false;
	} else {
		return true;
	}

}

function SaveData() {
	global $data, $surveyMan;
	
	$data['surveyDate'] = Date("Y-m-d");
	
	$id = $surveyMan->InsertSurvey($data);
	
	if ($id > 0) {
		$data['surveyID'] = $id;
		return true;
	} else {
		return false;
	}

}



function DrawRadioAgree($var, $question, $type, $data, $errors, &$shaded, &$CONTENT)
{
	$CONTENT .= "
		<tr".toggleShaded($shaded).">
		<td width=\"5%\"  class=\"nowrap\"><div align=\"right\">";
	if (isset($errors[$var]) && $errors[$var]) { 
		$CONTENT .= "<span class=\"error_indicator\"><b>!</b></span>";
	} else {
		$CONTENT .= "&nbsp;";
	}
	$CONTENT .= "
		</td>
		<td colspan=\"2\"><span class=\"form_label\">$question</span>
		</td>
		</tr>";
				
	// prepare the radio button checked variables
	$checked_1 = (isset($data[$var]) && $data[$var] == "1") ? " checked=\"checked\"" : "";
	$checked_2 = (isset($data[$var]) && $data[$var] == "2") ? " checked=\"checked\"" : "";
	$checked_3 = (isset($data[$var]) && $data[$var] == "3") ? " checked=\"checked\"" : "";
	$checked_4 = (isset($data[$var]) && $data[$var] == "4") ? " checked=\"checked\"" : "";
	$checked_5 = (isset($data[$var]) && $data[$var] == "5") ? " checked=\"checked\"" : "";
	$checked_6 = (isset($data[$var]) && $data[$var] == "6") ? " checked=\"checked\"" : "";		

	
	$CONTENT .= "
		<tr".displayShaded($shaded).">
  	<td width=\"5%\">&nbsp;</td>
		<td width=\"10%\" valign=\"top\"><span class=\"form_label\">&nbsp;</span></td>
		<td width=\"85%\" valign=\"top\"><span class=\"form_field\">
			<table width=\"100%\" border=\"0\">
			<tr>
				<td width=\"15%\" align=\"center\"><input type=\"radio\" name=\"" . $var . "\" value=\"1\" title=\"1\"$checked_1 /></td>
  			<td width=\"15%\" align=\"center\"><input type=\"radio\" name=\"" . $var . "\" value=\"2\" title=\"2\"$checked_2 /></td>
  			<td width=\"15%\" align=\"center\"><input type=\"radio\" name=\"" . $var . "\" value=\"3\" title=\"3\"$checked_3 /></td>
   			<td width=\"15%\" align=\"center\"><input type=\"radio\" name=\"" . $var . "\" value=\"4\" title=\"4\"$checked_4 /></td>
   			<td width=\"15%\" align=\"center\"><input type=\"radio\" name=\"" . $var . "\" value=\"5\" title=\"5\"$checked_5 /></td>
   			<td width=\"10%\">&nbsp;</td>
				<td width=\"15%\" align=\"center\"><input type=\"radio\" name=\"" . $var . "\" value=\"6\" title=\"5\"$checked_6 /></td>
			</tr>
			<tr>";
	
	if ($type == 1) {
		$CONTENT .= "
				<td width=\"15%\" align=\"center\">strongly<br>disagree</td>
  			<td width=\"15%\" align=\"center\">disagree</td>
  			<td width=\"15%\" align=\"center\">neutral</td>
   			<td width=\"15%\" align=\"center\">agree</td>
   			<td width=\"15%\" align=\"center\">strongly<br>agree</td>";
  } elseif ($type == 2) {
  	$CONTENT .= "
				<td width=\"15%\" align=\"center\">very<br>unimportant</td>
  			<td width=\"15%\" align=\"center\">unimportant</td>
  			<td width=\"15%\" align=\"center\">neutral</td>
   			<td width=\"15%\" align=\"center\">important</td>
   			<td width=\"15%\" align=\"center\">very<br>important</td>";
  } 
  $CONTENT .= "
   			<td width=\"10%\">&nbsp;</td>
   			<td width=\"15%\" align=\"center\">no<br>opinion</td>
			</tr>
			</table>
 	 		</span></td>
  	</tr>";
  	
}

function toggleShaded(&$shaded) {
	$shaded = !$shaded;
	return displayShaded($shaded);
}

function displayShaded($shaded) {
	if ($shaded) {
		return " class=\"shaded\"";
	} else {
		return "";
	}
}


  
?>


