
function isNotSelected(o, warning)
{
	if (o.selectedIndex==0)
	{
		alert(warning);
		return true;
	}
	return false;
}


// This function will make sure that all of the answers given are unique.
// If a duplicate is found, we will eliminate the duplicate.  The 
// algorithm is as follows:

// loop from the second answer to the last answer
// compare current answer to each previous answer
// if a duplicate is found, change the current answer
// if the current answer was correct, change the correct answer
//	to the one that was not changed.
function InsureUniqueAnswers(numAnswers, correctSpot, AnswerArray, FeedbackArray) 
{
	var i, j;
	for (i=2; i<=numAnswers; i++)
	{
		for (j=1; j<i; j++)
		{
			if (AnswerArray[i] == AnswerArray[j])
			{
				var numDigits;
				var whichDigit;
				var delta;

				numDigits  = GetNumberOfDigits(AnswerArray[j]);
				whichDigit = GetRandomNumber(1, numDigits);
				delta      = GetRandomNumber(-2, 2);

				if (0 == delta)
				{
					AnswerArray[i] = -1 * AnswerArray[i];
				}
				else
				{
					AnswerArray[i] = AnswerArray[i] + delta*Math.pow(10, whichDigit-1);
				}

				if (correctSpot == i)
				{
					correctSpot = j;
					FeedbackArray[j] = FeedbackArray[i];
				}
				FeedbackArray[i] = "Sorry - Wrong Answer"

				// reset j so that we compare the new wrong answer with 
				// all of the previous answers.
				j = 0;
			}
		}
	}

	return correctSpot;
}


// we have the arrays Answers and Responses that need to be mixed up.
// Since the arrays are already filled in, all that we need to do is 
// loop over the answers select which record goes in the i'th spot, 
// and then switching that record with the current one.
//
// We also need to keep track of which spot holds the correct answer.
function MixUpAnswers(numAnswers, correctSpot, AnswerArray, FeedbackArray) 
{
	var i;
	var whichSpot;

	for (i=1; i<numAnswers; i++)
	{
		whichSpot = GetRandomNumber(i, numAnswers);
		if (whichSpot != i)
		{
			var tempAnswer;
			tempAnswer = AnswerArray[i];
			AnswerArray[i] = AnswerArray[whichSpot];
			AnswerArray[whichSpot] = tempAnswer;

			var tempFeedback;
			tempFeedback = FeedbackArray[i];
			FeedbackArray[i] = FeedbackArray[whichSpot];
			FeedbackArray[whichSpot] = tempFeedback;

			if (whichSpot == correctSpot)
				correctSpot = i;
			else if (i == correctSpot)
				correctSpot = whichSpot;
		}
	}

	return correctSpot;
}


