//<![CDATA[

<!--

function Client(){

	this.min = false; if (document.getElementById){this.min = true;};

	this.ua = navigator.userAgent;
	this.name = navigator.appName;
	this.ver = navigator.appVersion;  


	this.mac = (this.ver.indexOf('Mac') != -1);
	this.win = (this.ver.indexOf('Windows') != -1);


	this.gecko = (this.ua.indexOf('Gecko') > 1);
	if (this.gecko){
		this.geckoVer = parseInt(this.ua.substring(this.ua.indexOf('Gecko')+6, this.ua.length));
		if (this.geckoVer < 20020000){this.min = false;}
	}
	

	this.firebird = (this.ua.indexOf('Firebird') > 1);
	

	this.safari = (this.ua.indexOf('Safari') > 1);
	if (this.safari){
		this.gecko = false;
	}
	

	this.ie = (this.ua.indexOf('MSIE') > 0);
	if (this.ie){
		this.ieVer = parseFloat(this.ua.substring(this.ua.indexOf('MSIE')+5, this.ua.length));
		if (this.ieVer < 5.5){this.min = false;}
	}
	

	this.opera = (this.ua.indexOf('Opera') > 0);
	if (this.opera){
		this.operaVer = parseFloat(this.ua.substring(this.ua.indexOf('Opera')+6, this.ua.length));
		if (this.operaVer < 7.04){this.min = false;}
	}
	if (this.min == false){
		alert('Su navegador no controla bien esta página.');
	}
	

	this.ie5mac = (this.ie&&this.mac&&(this.ieVer<6));
}

var C = new Client();

//for (prop in C){
//	alert(prop + ': ' + C[prop]);
//}

//[strNavBarJS]
function NavBtnOver(Btn){
	if (Btn.className != 'NavButtonDown'){Btn.className = 'NavButtonUp';}
}

function NavBtnOut(Btn){
	Btn.className = 'NavButton';
}

function NavBtnDown(Btn){
	Btn.className = 'NavButtonDown';
}
//[/strNavBarJS]

function FuncBtnOver(Btn){
	if (Btn.className != 'FuncButtonDown'){Btn.className = 'FuncButtonUp';}
}

function FuncBtnOut(Btn){
	Btn.className = 'FuncButton';
}

function FuncBtnDown(Btn){
	Btn.className = 'FuncButtonDown';
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		if (document.getElementById('CheckButton2') != null){
			document.getElementById('CheckButton2').focus();
		}
		else{
			document.getElementsByTagName('button')[0].focus();
		}
	}
}

var andlmund = 1000;

function ShowMessage(jusIs){
	var TifNort = jusIs + '<br /><br />';
	document.getElementById('FeedbackContent').innerHTML = TifNort;
	var Iscab = document.getElementById('FeedbackDiv');
	andlmund++;
	Iscab.style.zIndex = andlmund;
	Iscab.style.top = TopSettingWithScrollOffset(30) + 'px';

	Iscab.style.display = 'block';

	ShowElements(false, 'input');
	ShowElements(false, 'select');
	ShowElements(false, 'object');


	setTimeout("document.getElementById('FeedbackOKButton').focus()", 50);
	

}

function ShowElements(Show, TagName){

	if (C.ie){
		var Pirtfj = document.getElementsByTagName(TagName);
		for (var i=0; i<Pirtfj.length; i++){
			if (Show == true){
				Pirtfj[i].style.display = 'inline';
			}
			else{
				Pirtfj[i].style.display = 'none';
			}
		}
	} 
}

function HideFeedback(){
	document.getElementById('FeedbackDiv').style.display = 'none';
	ShowElements(true, 'input');
	ShowElements(true, 'select');
	ShowElements(true, 'object');
	if (felip == true){
		Finish();
	}
}


function PageDim(){

	this.W = 600;
	this.H = 400;
	this.W = document.getElementsByTagName('body')[0].clientWidth;
	this.H = document.getElementsByTagName('body')[0].clientHeight;
}

var Morg = null;

function GetPageXY(El) {
	var BeteY = {x: 0, y: 0};
	while(El){
		BeteY.x += El.offsetLeft;
		BeteY.y += El.offsetTop;
		El = El.offsetParent;
	}
	return BeteY;
}

function GetScrollTop(){
	if (document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	else{
		if (document.body){
 			return document.body.scrollTop;
		}
		else{
			return window.pageYOffset;
		}
	}
}

function GetViewportHeight(){
	if (window.innerHeight){
		return window.innerHeight;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var Cand = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + Cand; 
}


var puntcrr = false;

function SuppressBackspace(e){ 
	if (puntcrr == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var malllbet = false;

	if (thisKey == 8) {
		malllbet = true;
	}

	if (malllbet == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	if (window.addEventListener){
		window.addEventListener('keypress',SuppressBackspace,false);
	}
}

function ReduceItems(InArray, ReduceToSize){
	var Carin=0;
	var MallPl=0;
	while (InArray.length > ReduceToSize){
		Carin = Math.floor(InArray.length*Math.random());
		InArray.splice(Carin, 1);
	}
}

function Shuffle(InArray){
	var Saldeeg;
	var marrddo = new Array();
	var Len = InArray.length;

	var MallPl = Len;

	for (var i=0; i<Len; i++){
		marrddo[i] = InArray[i];
	}

	for (i=0; i<Len; i++){
		Saldeeg = Math.floor(MallPl  *  Math.random());
		InArray[i] = marrddo[Saldeeg];

		for (var k=Saldeeg; k < (MallPl-1); k++) {
			marrddo[k] = marrddo[k+1];
		}
		MallPl--;
	}
	return InArray;
}

function WriteToInstructions(jusIs) {
	document.getElementById('InstructionsDiv').innerHTML = jusIs;

}

function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function TrimString(InString){
        var x = 0;

        if (InString.length != 0) {
                while ((InString.charAt(InString.length - 1) == '\u0020') || (InString.charAt(InString.length - 1) == '\u000A') || (InString.charAt(InString.length - 1) == '\u000D')){
                        InString = InString.substring(0, InString.length - 1)
                }

                while ((InString.charAt(0) == '\u0020') || (InString.charAt(0) == '\u000A') || (InString.charAt(0) == '\u000D')){
                        InString = InString.substring(1, InString.length)
                }

                while (InString.indexOf('  ') != -1) {
                        x = InString.indexOf('  ')
                        InString = InString.substring(0, x) + InString.substring(x+1, InString.length)
                 }

                return InString;
        }

        else {
                return '';
        }
}

function FindLongest(InArray){
	if (InArray.length < 1){return -1;}

	var Ronddz = 0;
	for (var i=1; i<InArray.length; i++){
		if (InArray[i].length > InArray[Ronddz].length){
			Ronddz = i;
		}
	}
	return Ronddz;
}


function IsCombiningDiacritic(CharNum){
	var ParMalg = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
	ParMalg = ParMalg || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
	return ParMalg;
}

function IsCJK(CharNum){
	return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}


function ClearTextBoxes(){
	var Mnkk = document.getElementsByTagName('input');
	for (var i=0; i<Mnkk.length; i++){
		if ((Mnkk[i].id.indexOf('Guess') > -1)||(Mnkk[i].id.indexOf('Gap') > -1)){
			Mnkk[i].value = '';
		}
		if (Mnkk[i].id.indexOf('Chk') > -1){
			Mnkk[i].checked = '';
		}
	}
}


function Array_IndexOf(Input){
	var ParMalg = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			ParMalg = i;
		}
	}
	return ParMalg;
}
Array.prototype.indexOf = Array_IndexOf;


function RemoveBottomNavBarForIE(){
	if ((C.ie)&&(document.getElementById('Reading') != null)){
		if (document.getElementById('BottomNavBar') != null){
			document.getElementById('TheBody').removeChild(document.getElementById('BottomNavBar'));
		}
	}
}



var Tgagg= (new Date()).getTime();
var Tgakkl = 30000;
var Mhhna = ''; 

function Finish(){

	if (document.store != null){
		Frm = document.store;
		Frm.starttime.value = HPNStartTime;
		Frm.endtime.value = (new Date()).getTime();
		Frm.mark.value = Score;
		Frm.detail.value = Mhhna;
		Frm.submit();
	}
}


var Carmel = 0;
var Orue = ':-)';
var Gary = ':-(';
var Canit = '<br>Tu porcentaje de acierto es del';
var rtecg= true;
var marcai= 'El número de aciertos a la primera es de:';
var ariet= false;
var urib = false;
var gainz = false;
var pedr = '¡Bien!';
var adrn = 'Tienes que volver a repetirlo.';
var sant = 20;
var jua= 0;
var felip = false;
var NDRANan = null;
var santmn = new Array();
var mateok = false;
var judta = new Array();
var jusIs = '';
var Zebd = false;
var Nosqv = '';


var nstypww = '';

function CompleteEmptyFeedback(){
	var Parrill, ANum;
	for (Parrill=0; Parrill<I.length; Parrill++){

		if (I[Parrill][2] != '3'){
  		for (ANum = 0; ANum<I[Parrill][3].length; ANum++){
  			if (I[Parrill][3][ANum][1].length < 1){
  				if (I[Parrill][3][ANum][2] > 0){
  					I[Parrill][3][ANum][1] = pedr;
  				}
  				else{
  					I[Parrill][3][ANum][1] = adrn;
  				}
  			}
  		}
		}
	}
}

function SetUpQuestions(){
	var Ejercct = new Array(); 
	var Legg = new Array();
	var i, MallPl;
	NDRANan = document.getElementById('Questions');
	while (NDRANan.getElementsByTagName('li').length > 0){
		Legg.push(NDRANan.removeChild(NDRANan.getElementsByTagName('li')[0]));
	}
	var Mondrkk = 0;
	if (sant > Legg.length){
		sant = Legg.length;
	}
	while (sant < Legg.length){
		Mondrkk = Math.floor(Legg.length*Math.random());
		for (MallPl=Mondrkk; MallPl<(Legg.length-1); MallPl++){
			Legg[MallPl] = Legg[MallPl+1];
		}
		Legg.length = Legg.length-1;
	}
	if (urib == true){
		Legg = Shuffle(Legg);
	}
	if (gainz == true){
		var Arzza;
		for (var i=0; i<Legg.length; i++){
			Arzza = Legg[i].getElementsByTagName('ol')[0];
			if (Arzza != null){
  			Ejercct.length = 0;
				while (Arzza.getElementsByTagName('li').length > 0){
					Ejercct.push(Arzza.removeChild(Arzza.getElementsByTagName('li')[0]));
				}
				Ejercct = Shuffle(Ejercct);
				for (MallPl=0; MallPl<Ejercct.length; MallPl++){
					Arzza.appendChild(Ejercct[MallPl]);
				}
			}
		}
	}
	
	for (i=0; i<Legg.length; i++){
		NDRANan.appendChild(Legg[i]);
		santmn[santmn.length] = Legg[i];
	}


	santmn[0].style.display = '';
	

	for (i=1; i<santmn.length; i++){
		santmn[i].style.display = 'none';
	}		
	SetQNumReadout();
	
	SetFocusToTextbox();
}

function SetFocusToTextbox(){

	if (santmn[Carmel].getElementsByTagName('input')[0] != null){
		santmn[Carmel].getElementsByTagName('input')[0].focus();

		if (document.getElementById('CharacterKeypad') != null){
			document.getElementById('CharacterKeypad').style.display = 'block';
		}
	}
	else{
  	if (santmn[Carmel].getElementsByTagName('textarea')[0] != null){
  		santmn[Carmel].getElementsByTagName('textarea')[0].focus();	

			if (document.getElementById('CharacterKeypad') != null){
				document.getElementById('CharacterKeypad').style.display = 'block';
			}
		}

		else{
			if (document.getElementById('CharacterKeypad') != null){
				document.getElementById('CharacterKeypad').style.display = 'none';
			}
		}
	}
}

function ChangeQ(ChangeBy){


	if (((Carmel + ChangeBy) < 0)||((Carmel + ChangeBy) >= santmn.length)){return;}
	santmn[Carmel].style.display = 'none';
	Carmel += ChangeBy;
	santmn[Carmel].style.display = '';

	ShowSpecialReadingForQuestion();
	SetQNumReadout();
	SetFocusToTextbox();
}

var LondEstamb = false;
function ShowSpecialReadingForQuestion(){

	if (document.getElementById('ReadingDiv') != null){
		if (LondEstamb == true){
			document.getElementById('ReadingDiv').innerHTML = '';
		}
		if (santmn[Carmel] != null){
			var Tornnd = santmn[Carmel].childNodes;
			for (var i=0; i<Tornnd.length; i++){
			if (Tornnd[i].className=="HiddenReading"){
					document.getElementById('ReadingDiv').innerHTML = Tornnd[i].innerHTML;
					LondEstamb = true;

					if (document.getElementById('ShowMethodButton') != null){
						document.getElementById('ShowMethodButton').style.display = 'none';
					}
				}
			}	
		}
	}
}

function SetQNumReadout(){
	document.getElementById('QNumReadout').innerHTML = (Carmel+1) + ' / ' + santmn.length;
	if ((Carmel+1) >= santmn.length){
		if (document.getElementById('NextQButton') != null){
			document.getElementById('NextQButton').style.visibility = 'hidden';
		}
	}
	else{
		if (document.getElementById('NextQButton') != null){
			document.getElementById('NextQButton').style.visibility = 'visible';
		}
	}
	if (Carmel <= 0){
		if (document.getElementById('PrevQButton') != null){
			document.getElementById('PrevQButton').style.visibility = 'hidden';
		}
	}
	else{
		if (document.getElementById('PrevQButton') != null){
			document.getElementById('PrevQButton').style.visibility = 'visible';
		}
	}
}

I=new Array();
I[0]=new Array();I[0][0]=100;
I[0][1]='';
I[0][2]='1';
I[0][3]=new Array();
I[0][3][0]=new Array('a-gua=diptongo','',1,100,1);

I[1]=new Array();I[1][0]=100;
I[1][1]='';
I[1][2]='1';
I[1][3]=new Array();
I[1][3][0]=new Array('ca-e-mos=hiato','',1,100,1);

I[2]=new Array();I[2][0]=100;
I[2][1]='';
I[2][2]='1';
I[2][3]=new Array();
I[2][3][0]=new Array('be-a-to=hiato','',1,100,1);

I[3]=new Array();I[3][0]=100;
I[3][1]='';
I[3][2]='1';
I[3][3]=new Array();
I[3][3][0]=new Array('ce-rra-je-r\u00ed-a=hiato','',1,100,1);

I[4]=new Array();I[4][0]=100;
I[4][1]='';
I[4][2]='1';
I[4][3]=new Array();
I[4][3][0]=new Array('or-to-gra-f\u00ed-a=hiato','',1,100,1);

I[5]=new Array();I[5][0]=100;
I[5][1]='';
I[5][2]='1';
I[5][3]=new Array();
I[5][3][0]=new Array('pun-t\u00fa-o=hiato','',1,100,1);

I[6]=new Array();I[6][0]=100;
I[6][1]='';
I[6][2]='1';
I[6][3]=new Array();
I[6][3][0]=new Array('a-pio=diptongo','',1,100,1);

I[7]=new Array();I[7][0]=100;
I[7][1]='';
I[7][2]='1';
I[7][3]=new Array();
I[7][3][0]=new Array('an-gus-tia=diptongo','',1,100,1);

I[8]=new Array();I[8][0]=100;
I[8][1]='';
I[8][2]='1';
I[8][3]=new Array();
I[8][3][0]=new Array('fra-ca-sa-r\u00ed-a=hiato','',1,100,1);

I[9]=new Array();I[9][0]=100;
I[9][1]='';
I[9][2]='1';
I[9][3]=new Array();
I[9][3][0]=new Array('a-ca-de-mia=diptongo','',1,100,1);

I[10]=new Array();I[10][0]=100;
I[10][1]='';
I[10][2]='1';
I[10][3]=new Array();
I[10][3][0]=new Array('pio-jo=diptongo','',1,100,1);

I[11]=new Array();I[11][0]=100;
I[11][1]='';
I[11][2]='1';
I[11][3]=new Array();
I[11][3][0]=new Array('trans-gre-si\u00f3n=diptongo','',1,100,1);

I[12]=new Array();I[12][0]=100;
I[12][1]='';
I[12][2]='1';
I[12][3]=new Array();
I[12][3][0]=new Array('mer-ce-r\u00ed-a=hiato','',1,100,1);

I[13]=new Array();I[13][0]=100;
I[13][1]='';
I[13][2]='1';
I[13][3]=new Array();
I[13][3][0]=new Array('i-nau-di-to=diptongo','',1,100,1);

I[14]=new Array();I[14][0]=100;
I[14][1]='';
I[14][2]='1';
I[14][3]=new Array();
I[14][3][0]=new Array('abs-ten-ci\u00f3n=diptongo','',1,100,1);

I[15]=new Array();I[15][0]=100;
I[15][1]='';
I[15][2]='1';
I[15][3]=new Array();
I[15][3][0]=new Array('obs-truir=diptongo','',1,100,1);

I[16]=new Array();I[16][0]=100;
I[16][1]='';
I[16][2]='1';
I[16][3]=new Array();
I[16][3][0]=new Array('sus-tra-er=hiato','',1,100,1);

I[17]=new Array();I[17][0]=100;
I[17][1]='';
I[17][2]='1';
I[17][3]=new Array();
I[17][3][0]=new Array('Ma-r\u00ed-a=hiato','',1,100,1);

I[18]=new Array();I[18][0]=100;
I[18][1]='';
I[18][2]='1';
I[18][3]=new Array();
I[18][3][0]=new Array('abs-te-mio=diptongo','',1,100,1);

I[19]=new Array();I[19][0]=100;
I[19][1]='';
I[19][2]='1';
I[19][3]=new Array();
I[19][3][0]=new Array('po-\u00e9-ti-co=hiato','',1,100,1);


function StartUp(){
	RemoveBottomNavBarForIE();

	if (sant < 2){
		document.getElementById('QNav').style.display = 'none';
	}
	
	Nosqv = document.getElementById('InstructionsDiv').innerHTML;
		
	CompleteEmptyFeedback();

	SetUpQuestions();
	ClearTextBoxes();
	CreateStatusArray();
	
	if (document.location.search.length > 0){
		if (urib == false){
			var Huchi = parseInt(document.location.search.substring(1,document.location.search.length))-1;
			if (Huchi <= sant){
				ChangeQ(Huchi);
			}
		}
	}

	ShowSpecialReadingForQuestion();
}

function ShowHideQuestions(){
	FuncBtnOut(document.getElementById('ShowMethodButton'));
	document.getElementById('ShowMethodButton').style.display = 'none';
	if (mateok == false){
		for (var i=0; i<santmn.length; i++){
				santmn[i].style.display = '';
			}
		document.getElementById('Questions').style.listStyleType = 'decimal';
		document.getElementById('OneByOneReadout').style.display = 'none';
		document.getElementById('ShowMethodButton').innerHTML = ShowOneByOneCaption;
		mateok = true;
	}
	else{
		for (var i=0; i<santmn.length; i++){
				if (i != Carmel){
					santmn[i].style.display = 'none';
				}
			}
		document.getElementById('Questions').style.listStyleType = 'none';
		document.getElementById('OneByOneReadout').style.display = '';
		document.getElementById('ShowMethodButton').innerHTML = ShowAllQuestionsCaption;
		mateok = false;	
	}
	document.getElementById('ShowMethodButton').style.display = 'inline';
}

function CreateStatusArray(){
	var Parrill, ANum;

	for (Parrill=0; Parrill<I.length; Parrill++){

		if (document.getElementById('Q_' + Parrill) != null){
			judta[Parrill] = new Array();
			judta[Parrill][0] = -1; 
			judta[Parrill][1] = new Array(); 
			for (ANum = 0; ANum<I[Parrill][3].length; ANum++){
				judta[Parrill][1][ANum] = 0; 
			}
			judta[Parrill][2] = 0; 
			judta[Parrill][3] = 0; 
			judta[Parrill][4] = 0; 
			judta[Parrill][5] = ''; 
		}
		else{
			judta[Parrill] = null;
		}
	}
}





function CalculateOverallScore(){
	var HuelServ = 0;
	var HuelRued= 0;
	
	for (var Parrill=0; Parrill<judta.length; Parrill++){
		if (judta[Parrill] != null){
			if (judta[Parrill][0] > -1){
				HuelServ += I[Parrill][0];
				HuelRued+= (I[Parrill][0] * judta[Parrill][0]);
			}
		}
	}
	if (HuelServ > 0){
		jua= Math.floor((TotalScore/HuelServ)*100);
	}
	else{

		jua= 100; 
	}
}

function CheckFinished(){
	var HuelAd = '';
	var HuelMalgg = true;
	for (var Parrill=0; Parrill<judta.length; Parrill++){
		if (judta[Parrill] != null){
			if (judta[Parrill][0] < 0){
				HuelMalgg = false;
			}
		}
	}
	if (HuelMalgg == true){
	
		CalculateOverallScore();
		HuelAd = Canit + ' ' + jua+ '%.';
		if (ariet== true){
			var CFT = 0;
			for (Parrill=0; Parrill<judta.length; Parrill++){
				if (judta[Parrill] != null){
					if (judta[Parrill][0] >= 1){
						CFT++;
					}
				}
			}
			HuelAd += '<br />' + marcai+ ' ' + CFT + '/' + sant;
		}
		WriteToInstructions(HuelAd);
		
		felip == true;

		Zebd = true;
		Locked = true;
		


		felip = true;
		Mhhna = '<?xml version="1.0"?><hpnetresult><fields>';
		for (Parrill=0; Parrill<judta.length; Parrill++){
			if (judta[Parrill] != null){
				if (judta[Parrill][5].length > 0){
					Mhhna += '<field><fieldname>Question #' + (Parrill+1) + '</fieldname><fieldtype>question-tracking</fieldtype><fieldlabel>Q ' + (Parrill+1) + '</fieldlabel><fieldlabelid>QuestionTrackingField</fieldlabelid><fielddata>' + judta[Parrill][5] + '</fielddata></field>';
				}
			}
		}
		Mhhna += '</fields></hpnetresult>';
		setTimeout('Finish()', Tgakkl);
	}
}

var RayVall = false;
var RayAlm = true;
var RaySeg = 'Falta una respuesta. Escríbela.';
var RayGua = 2;
var RayGoy = 'Esta respuesta no es del todo correcta. Vuelve a intentarlo.';
var RayPRR = 'Respuesta acertada.';
var RayMrr = 'La letra que viene a continuación es la:';
var RayFulm = null;

function TrackFocus(BoxID){
	puntcrr = true;
	RayFulm = document.getElementById(BoxID);
}

function LeaveGap(){
	puntcrr = false;
}

function TypeChars(Chars){
	if (RayFulm != null){

		if (RayFulm.style.display != 'none'){
			RayFulm.value += Chars;
			RayFulm.focus();
		}
	}
}

function CheckGuess(Guess, Answer, RayVall, ZylMad, jusIs){
	this.Guess = Guess;
	this.Answer = Answer;
	this.ZylMad = ZylMad;
	this.jusIs = jusIs;
	if (RayVall == false){
		this.WorkingGuess = Guess.toLowerCase();
		this.WorkingAnswer = Answer.toLowerCase();
	}
	else{
		this.WorkingGuess = Guess;
		this.WorkingAnswer = Answer;				
	}
	this.Hint = '';
	this.HintPenalty = 1/Answer.length;
	this.CorrectStart = '';
	this.WrongMiddle = '';
	this.CorrectEnd = '';
	this.OlivRec = 0;
	this.DoCheck();
}

function CheckGuess_DoCheck(){

	if (this.WorkingAnswer == this.WorkingGuess){
		this.OlivRec = 100;
		this.CorrectStart = this.Guess;
	return;
	}

	var i = 0;
	var MallZnn = 0;
	while (this.WorkingAnswer.charAt(i) == this.WorkingGuess.charAt(i)){
		i++;
		MallZnn++;
	}


	this.Hint = this.Answer.charAt(i);
	
	this.CorrectStart = this.Guess.substring(0, i);
	

	if (i<this.Guess.length){
	

		var MallPl = this.WorkingGuess.length-1;
		var k = this.WorkingAnswer.length-1;
		while ((MallPl>=i)&&((this.WorkingAnswer.charAt(k) == this.WorkingGuess.charAt(MallPl))&&(MallZnn < this.Answer.length))){
			MallZnn++;
			MallPl--;
			k--;
		}
		this.CorrectEnd = this.Guess.substring(MallPl+1, this.Guess.length);
		this.WrongMiddle = this.Guess.substring(i, MallPl+1);
	}
	if (TrimString(this.WrongMiddle).length < 1){this.WrongMiddle = '_';}

	if (MallZnn < this.Answer.length){
		this.OlivRec = Math.floor(100*MallZnn)/this.Answer.length;
	}
	else{
		this.OlivRec = Math.floor((100 * MallZnn)/this.Guess.length);
	}	
}

CheckGuess.prototype.DoCheck = CheckGuess_DoCheck;

function CheckAnswerArray(RayVall){
	this.RayVall = RayVall;
	this.Answers = new Array();
	this.jua= 0;
	this.jusIs = '';
	this.Hint = '';
	this.HintPenalty = 0;
	this.MatchedAnswerLength = 1;
	this.CompleteMatch = false;
	this.MatchNum = -1;
}

function CheckAnswerArray_AddAnswer(Guess, Answer, ZylMad, jusIs){
	this.Answers.push(new CheckGuess(Guess, Answer, this.RayVall, ZylMad, jusIs));
}

CheckAnswerArray.prototype.AddAnswer = CheckAnswerArray_AddAnswer;

function CheckAnswerArray_ClearAll(){
	this.Answers.length = 0;
}

CheckAnswerArray.prototype.ClearAll = CheckAnswerArray_ClearAll;

function CheckAnswerArray_GetBestMatch(){

	for (var i=0; i<this.Answers.length; i++){
		if (this.Answers[i].OlivRec == 100){
			this.jusIs = this.Answers[i].jusIs;
			this.jua= this.Answers[i].ZylMad;
			this.CompleteMatch = true;
			this.MatchNum = i;
			return;
		}
	}

	var OlivRec = 0;
	var OlvKig = -1;
	for (i=0; i<this.Answers.length; i++){
		if ((this.Answers[i].OlivRec > OlivRec)&&(this.Answers[i].ZylMad == 100)){
			OlvKig = i;
			OlivRec = this.Answers[i].OlivRec;
		}
	}
	if (OlvKig > -1){
		this.jua= this.Answers[OlvKig].OlivRec;
		this.jusIs = RayGoy + ' ';
		this.jusIs += '<span class="PartialAnswer">' + this.Answers[OlvKig].CorrectStart;
		this.jusIs += '<span class="Highlight">' + this.Answers[OlvKig].WrongMiddle + '</span>';
		this.jusIs += this.Answers[OlvKig].CorrectEnd + '</span>';
		this.Hint = '<span class="PartialAnswer">' + this.Answers[OlvKig].CorrectStart;
		this.Hint += '<span class="Highlight">' + this.Answers[OlvKig].Hint + '</span></span>';
		this.HintPenalty = this.Answers[OlvKig].HintPenalty;
	}
	else{
		this.jua= 0;
		this.jusIs = '';
	}
}

CheckAnswerArray.prototype.GetBestMatch = CheckAnswerArray_GetBestMatch;

function CheckShortAnswer(Parrill){

	if ((judta[Parrill].length < 1)||(felip == true)){return;}
	
	if (judta[Parrill][0] > -1){return;}

	var AlmMarc = TrimString(document.getElementById('Q_' + Parrill + '_Guess').value);
	
	if (AlmMarc.length < 1){
		ShowMessage(RaySeg);
		return;
	}

	judta[Parrill][2]++;
	
	var CA = new CheckAnswerArray(RayVall);

	CA.ClearAll();
	for (var ANum=0; ANum<I[Parrill][3].length; ANum++){
		CA.AddAnswer(AlmMarc, I[Parrill][3][ANum][0], I[Parrill][3][ANum][3], I[Parrill][3][ANum][1]);
	}
	CA.GetBestMatch();
	
	if (CA.MatchNum > -1){
		judta[Parrill][5] += String.fromCharCode(65+CA.MatchNum) + ',';
	}

	judta[Parrill][3] += CA.Score;
	
	if (CA.CompleteMatch == true){
		

		if (CA.jua== 100){

			CalculateShortAnsQuestionScore(Parrill);

			if (RayAlm == true){
				var AlsoCorrectList = GetCorrectList(Parrill, AlmMarc, false);
				if (AlsoCorrectList.length > 0){
					CA.jusIs += '<br />' + RayPRR + '<br />' + AlsoCorrectList;
				}
			}	
		

			if (rtecg== true){
				CalculateOverallScore();
				CA.jusIs += '<br />' + Canit + ' ' + jua+ '%.';
				WriteToInstructions(Canit + ' ' + jua+ '%.');
			}
			ShowMessage(CA.jusIs);

			ReplaceGuessBox(Parrill, AlmMarc);
			CheckFinished();
			return;
		}
	}
	

	if (CA.jusIs.length < 1){CA.jusIs = adrn;}

	if (felip == false){
		WriteToInstructions(Nosqv);
	}	
	ShowMessage(CA.jusIs);


	if (judta[Parrill][2] >= RayGua){
		SwitchHybridDisplay(Parrill);
	}
}

function CalculateShortAnsQuestionScore(Parrill){
	var ZyllX = judta[Parrill][2] + judta[Parrill][4]; 
	var ZylMad = judta[Parrill][3];
	var ZilEur = judta[Parrill][4];


	if (judta[Parrill][0] < 0){
		if (ZilEur >= 1){
			judta[Parrill][0] = 0;
		}
		else{
			judta[Parrill][0] = (ZylMad/(100*ZyllX));
		}
		if (judta[Parrill][0] < 0){
			judta[Parrill][0] = 0;
		}
	}
}

function SwitchHybridDisplay(Parrill){
	if (document.getElementById('Q_' + Parrill + '_Hybrid_MC') != null){
		document.getElementById('Q_' + Parrill + '_Hybrid_MC').style.display = '';
		if (document.getElementById('Q_' + Parrill + '_SA') != null){
			document.getElementById('Q_' + Parrill + '_SA').style.display = 'none';
		}
	}
}

function GetCorrectArray(Parrill){
	var ParMalg = new Array();
	for (var ANum=0; ANum<I[Parrill][3].length; ANum++){
		if (I[Parrill][3][ANum][2] == 1){ 
			ParMalg.push(I[Parrill][3][ANum][0]);
		}
	}	
	return ParMalg;
}

function GetCorrectList(Parrill, Answer, IncludeAnswer){
	var Arzza = GetCorrectArray(Parrill);
	var ParMalg = '';
	for (var ANum=0; ANum<Arzza.length; ANum++){
		if ((IncludeAnswer == true)||(Arzza[ANum] != Answer)){
			ParMalg += Arzza[ANum] + '<br />';
		}
	}
	return ParMalg;
}

function GetFirstCorrectAnswer(Parrill){
	var Arzza = GetCorrectArray(Parrill);
	if (Arzza.length > 0){
		return Arzza[0];
	}
	else{
		return '';
	}
}

function ReplaceGuessBox(Parrill, Ans){
	if (document.getElementById('Q_' + Parrill + '_SA') != null){
		var El = document.getElementById('Q_' + Parrill + '_SA');
		while (El.childNodes.length > 0){
			El.removeChild(El.childNodes[0]);
		}
		var A = document.createElement('span');
		A.setAttribute('class', 'Answer');
		var Cand = document.createTextNode(Ans);
		A.appendChild(Cand);
		El.appendChild(A);
	}
}

function ShowAnswers(Parrill){

	if ((judta[Parrill].length < 1)||(felip == true)){return;}
	
	var Ans = GetCorrectList(Parrill, '', false);
	Ans = RayPRR + '<br />' + Ans;
	
	ShowMessage(Ans);
	
	if (judta[Parrill][0] < 1){
		judta[Parrill][0] = 0;
	}


	var FirstAns = GetFirstCorrectAnswer(Parrill);
	

	ReplaceGuessBox(Parrill, FirstAns);
	

	WriteToInstructions(Nosqv);
	

	CheckFinished();
}


function ShowHint(Parrill){

	if ((judta[Parrill].length < 1)||(felip == true)){return;}
	
	if (judta[Parrill][0] > -1){return;}

	var AlmMarc = document.getElementById('Q_' + Parrill + '_Guess').value;
	
	if (AlmMarc.length < 1){
		var Ans = GetFirstCorrectAnswer(Parrill);
		var Hint = Ans.charAt(0);
		ShowMessage(RayMrr + '<br />' + Hint);

		judta[Parrill][4] += (1/Ans.length);
		return;
	}


	judta[Parrill][2]++;
	
	var CA = new CheckAnswerArray(RayVall);

	CA.ClearAll();
	for (var ANum=0; ANum<I[Parrill][3].length; ANum++){

		if (I[Parrill][3][ANum][2] == 1){
			CA.AddAnswer(AlmMarc, I[Parrill][3][ANum][0], I[Parrill][3][ANum][3], I[Parrill][3][ANum][1]);
		}
	}
	CA.GetBestMatch();
	if (CA.CompleteMatch == true){

		CheckShortAnswer(Parrill);
		return;
	}
	else{
		if (CA.Hint.length > 0){
			ShowMessage(RayMrr + '<br />' + CA.Hint);
			judta[Parrill][4] += CA.HintPenalty;
		}
		else{
			ShowMessage(adrn + '<br />' + RayMrr + '<br />' + GetFirstCorrectAnswer(Parrill).charAt(0));
		}
	}
}

//-->

//]]>
