if(debug == 'true' || parent.ISDBSenrolled == 1)
	{NextEnabled = 1;}
else
	{NextEnabled = 0;}



function showCorrect()
{
	if(KCcheat == 'true')
		{
			
			var form = document.form1
			for (i = 0; i < form.Quiz.length; i++) 
				{
					if(vCorrectAnswer.charAt(i)==1) 
						{	form.elements[i].style.backgroundColor = '#F8F7C7';}						
				}
		}
}

var vAttempt = 1;

function Clicked()
{	
		//alert('this is the attempts: ' + vAttempt + ' and here are the max allowed tries: ' +  vTriesAllowed)

	var form = document.form1
	var vAnswered = 0
	var vResponse = ""
	var vCorrectCount = 0
	
	//checks to see if the question has been attempted or not
	for (var i=0; i < form.Quiz.length; i++)  
		{
			if(form.Quiz[i].checked) {vAnswered = 1}
			vResponse = vResponse + form.Quiz[i].checked*1	
		}
	if (vAnswered == 0)		{alert("\nYou need to answer the question to continue.")}
		
	else //there is a response	
		{  
		//alert(vAttempt+"======"+vTriesAllowed)
			if (vAttempt < vTriesAllowed)
				{
				  //they got it right
				  if (vResponse == vCorrectAnswer) 
					{DisplayFeedback('Correct',Feedback); vAttempt = vTriesAllowed}
					
				  //they got it wrong, and it's not the last available try
				  if (vResponse != vCorrectAnswer && vAttempt <= vTriesAllowed)
			  		{
						//alert(vResponse);
							for (i = 0; i < form.Quiz.length; i++) 
							{
								if (vResponse.charAt(i) == vCorrectAnswer.charAt(i))
									{	
									//it's correct, do nothing but increment the vCorrectCount counter
									if(form.Quiz[i].checked==1){vCorrectCount = vCorrectCount + 1}
									}
								 else
									{	
									//uncheck the incorrect ones
									form.Quiz[i].checked=0
									}
							
							}
							//tell them to try again and how many they got right
							if(vCorrectCount == 0)
								{DisplayFeedback('Incorrect','You did not answer any item correctly.  <strong>Please review the question and begin again.</strong> ')}
							else
								{DisplayFeedback('Incorrect','You answered ' + vCorrectCount + '</strong> of the items correctly.  Your wrong answers will be erased to allow you to try again.</p> <p><strong>Please click on Try Again and then select a new response for each "unanswered" item.  Remember, the remaining selected answers are correct! </strong>')}
							
					}		
					for (var i=0; i < document.form1.Quiz.length; i++) 
						{					
							 document.form1.Quiz[i].disabled=true;
							// alert("Cominggggg")
						}
				 }
				 
				 
				  //they still got it wrong on their last try	
			else
				{
				//alert("Elseeeeeeeee")
				  if (vResponse != vCorrectAnswer)		
				  	{
						//DisplayFeedback('Incorrect',Feedback)
						for (i = 0; i < form.Quiz.length; i++) 
							{
								if (vResponse.charAt(i) == vCorrectAnswer.charAt(i))
									{	
									//it's correct, do nothing but increment the vCorrectCount counter
									if(form.Quiz[i].checked==1){vCorrectCount = vCorrectCount + 1}
									}
							}
						//tell them to try again and how many they got right
					if(vCorrectCount == 0)
						{DisplayFeedback('Incorrect','You did not answer any item correctly.   </p><p>' + Feedback)}
					else
						{DisplayFeedback('Incorrect','You answered ' + vCorrectCount + '  of the items correctly. </strong></p><p>' + Feedback)}
								
					
					
					}	
				  if (vResponse == vCorrectAnswer) 		{DisplayFeedback('Correct',Feedback)}
				}	
					
					
		}	
}

function Navigate()
{
	
	if (vAttempt == vTriesAllowed)
		{
				//parent.goToNextPage();	
		}		
	if (vAttempt < vTriesAllowed)
		{
			document.getElementById('feedbackDiv').style.display = 'none';
			//document.getElementById('maincontent').style.display = 'block';	
			document.getElementById('content').focus();	
			//vTriesAllowed = vTriesAllowed - 1; 
			//document.getElementById('tries').innerHTML = " (Tries remaining: " + vTriesAllowed + ")"
			
				//make the unchecked items unavailable
			vTriesAllowed = vTriesAllowed - 1; 
				
				for (var i=0; i < document.form1.Quiz.length; i++) 
				{					
					 document.form1.Quiz[i].disabled=false;
				}
		}
}



function DisplayFeedback(Response,Feedback)
{
	//document.getElementById('maincontent').style.display = 'none';
	document.getElementById('feedbackDiv').style.display = 'block';	
	document.getElementById('feedbackDiv').focus();	
		
		
	if(Response == "Correct") {Answer = '<span style="color:#6e9017; font-weight:bold;">Correct.</span> Review the feedback below.  When you are ready to proceed, click the right arrow.'}; //<img src="images/NextBtn.jpg" alt="">
	if(Response == "Incorrect") {Answer = '<span style="color:#6e9017; font-weight:bold;">Incorrect.</span> Review the feedback below.  When you are ready to proceed, click the right arrow.'};
		
		FeedBackText = ''

		FeedBackText = FeedBackText + '<div id="FBtext" style="background-color:#FFFFFF; overflow:auto; padding:0px;" >';
		
		if ((vAttempt == vTriesAllowed  && Response == "Incorrect") || Response == "Correct"){FeedBackText = FeedBackText + '<p>' + Answer + '</p>'; setNextActive()}
		
		FeedBackText = FeedBackText + '<p>';
		FeedBackText = FeedBackText + Feedback;
		FeedBackText = FeedBackText + '</p></div>';
		
		if ((vAttempt != vTriesAllowed  && Response == "Incorrect"))
			{FeedBackText = FeedBackText + '<p align=center style="margin-top:10px;"><a href="#" onclick="Navigate();" onmouseover="document.tryagain.src=\'../images/tryAgainHi.gif\';" onmousedown="document.tryagain.src=\'../images/tryAgainDn.gif\';" onmouseout="document.tryagain.src=\'../images/tryAgain.gif\';" alt="Try Again" title="Try Again" ><img src="../images/tryAgain.gif" alt="Try Again" title="Try Again" border=0 name="tryagain"></a>';}
	
		document.getElementById('feedbackDiv').innerHTML=FeedBackText;
}


