
// This funtion is meant to check check box lists on each click, it prevents the user from choosing more than 3.
function onlyThreeCheck() 
{
   var chktotalq20 = 0;
   var chktotalq26 = 0;
   var chktotalq27 = 0;
   for(var count01 = 0; count01 < document.survey.question20.length; count01++)
   {
	  //Check question 20 to see if the user is clicking their 4th checkbox, if so tell them they are only allowed 3 and deselect the checkbox
      if(document.survey.question20[count01].checked) 
      {
         chktotalq20 = chktotalq20 + 1;
         if(chktotalq20 > 3)
         {
            alert("Please select only three.")
            document.survey.question20[count01].checked = false;
            return false;
         }
      }
	  //Check question 26 to see if the user is clicking their 4th checkbox, if so tell them they are only allowed 3 and deselect the checkbox
	  if(document.survey.question26[count01].checked) 
      {
         chktotalq26 = chktotalq26 + 1;
         if(chktotalq26 > 3)
         {
            alert("Please select only three.")
            document.survey.question26[count01].checked = false;
            return false;
         }
      }
	  //Check question 27 to see if the user is clicking their 4th checkbox, if so tell them they are only allowed 3 and deselect the checkbox
	  if(document.survey.question27[count01].checked) 
      {
         chktotalq27 = chktotalq27 + 1;
         if(chktotalq27 > 3)
         {
            alert("Please select only three.")
            document.survey.question27[count01].checked = false;
            return false;
         }
      }
   }
}

// This function is meant to alter the values of the "Other" fields in the "Choose 3" questions. It changes the value to what the user typed in the field.
function alterFormValues() 
{  
   //Check to see if the "Other" option for question 20 was chosen. If so change the value to be the text value.
   if(document.survey.question20[9].checked === true) 
   {
	  document.survey.question20[9].value = "Other: " + document.survey.q20other.value;
   }
   //Check to see if the "Other" option for question 26 was chosen. If so change the value to be the text value.
   if(document.survey.question26[9].checked === true) 
   {
	  document.survey.question26[9].value = "Other: " + document.survey.q26other.value;
   }
   //Check to see if the "Other" option for question 27 was chosen. If so change the value to be the text value.
   if(document.survey.question27[9].checked === true) 
   {
	  document.survey.question27[9].value = "Other: " + document.survey.q27other.value;
   }   
}
   
function setTeacherSurvey( itemId )
{
	thing = document.getElementById( 'question' + itemId );
	thing.innerHTML = "<input id=\"q" + itemId + "\" name=\"q" + itemId + "\" type=\"hidden\" value=\"-1\" />\n";
	for( i = 1; i <= 10; i++ )
	{
		thing.innerHTML += '<img src="/images/TeacherSurvey/nosel' + i + '.gif" onclick="switchPic( this, ' + i + ' )" />';
	}
}

function switchPic( itemId, numb )
{
	
	for( i = 0; i < 10; i++ )
	{
		if( i + 1 == numb )
			continue;
		itemId.parentNode.childNodes[i + 2].src = '/images/TeacherSurvey/nosel' + (i + 1) + '.gif';
	}
		
	itemId.src = '/images/TeacherSurvey/sel' + numb + '.gif';
	itemId.parentNode.childNodes[0].value = numb;
}

for( i = 1; i <= 10; i++ )
{
	pic = new Image();
	pic.src = '/images/TeacherSurvey/sel' + i + '.gif';
}
