// JavaScript Document
window.onload = function(){
	document.getElementById("txt1").disabled = false;
	document.getElementById("txt1").focus();
	}
function myFunction() {
    var a = document.getElementById("txt1");
    a.value = a.value.toLowerCase();
	var b = document.getElementById("txt2");
    b.value = b.value.toLowerCase();
	var c = document.getElementById("txt3");
    c.value = c.value.toLowerCase();
	var d = document.getElementById("txt4");
    d.value = d.value.toLowerCase();
	var e= document.getElementById("txt5");
    e.value = e.value.toLowerCase();
	var f = document.getElementById("txt6");
    f.value = f.value.toLowerCase();
}
function init(){
document.getElementById("txt1").disabled = false;
document.getElementById("txt1").focus();
document.getElementById("txt2").disabled = true;
document.getElementById("txt3").disabled = true;
document.getElementById("txt4").disabled = true;
document.getElementById("txt5").disabled = true;
document.getElementById("txt6").disabled = true;



var t1 = document.getElementById("txt1");
t1.addEventListener("keyup", verificar); 

function verificar(){
  var timer = null;
  clearTimeout(timer);
  timer = setTimeout(ver1, 10);
}

function ver1(){
  var cadena = " 3 tres";
  var palabra = document.getElementById("txt1").value;
  if (cadena.indexOf(palabra) != -1){
	  document.getElementById("txt1").style.color = "black";
    if(palabra == "3" || palabra == "tres"){
      document.getElementById("txt1").style.color = "green";
	  sg.sound("success-low");
	  sg.fadeOut('#img1');
	  sg.fadeIn('#img2');
      document.getElementById("txt1").disabled = true;
      document.getElementById("txt2").disabled = false;
	  document.getElementById("txt2").focus();
    }
    else{
      //document.getElementById("txt1").style.color = "red";
    }
  }
  else{
    document.getElementById("txt1").style.color = "red";
	sg.sound("error");
  }
}

var t2 = document.getElementById("txt2");
t2.addEventListener("keyup", verificar2); 

function verificar2(){
  var timer = null;
  clearTimeout(timer);
  timer = setTimeout(ver2, 10);
}

function ver2(){
  var cadena = " 3 tres";
  var palabra = document.getElementById("txt2").value;
  if (cadena.indexOf(palabra) != -1){
	  document.getElementById("txt2").style.color = "black";
    if(palabra == "3" || palabra == "tres"){
      document.getElementById("txt2").style.color = "green";
	  sg.sound("success-low");
	  sg.fadeOut('#img2');
	  sg.fadeIn('#img3');
      document.getElementById("txt2").disabled = true;
      document.getElementById("txt3").disabled = false;
	  document.getElementById("txt3").focus();
    }
    else{
      //document.getElementById("txt2").style.color = "red";
    }
  }
  else{
    document.getElementById("txt2").style.color = "red";
	sg.sound("error");
  }
}

var t3 = document.getElementById("txt3");
t3.addEventListener("keyup", verificar3); 

function verificar3(){
  var timer = null;
  clearTimeout(timer);
  timer = setTimeout(ver3, 10);
}

function ver3(){
  var cadena = " 3 tres";
  var palabra = document.getElementById("txt3").value;
  if (cadena.indexOf(palabra) != -1){
	  document.getElementById("txt3").style.color = "black";
    if(palabra == "3" || palabra == "tres"){
      document.getElementById("txt3").style.color = "green";
	  sg.sound("success-low");
	  sg.fadeOut('#img3');
	  sg.fadeIn('#img4');
      document.getElementById("txt3").disabled = true;
      document.getElementById("txt4").disabled = false;
	  document.getElementById("txt4").focus();
    }
    else{
     // document.getElementById("txt3").style.color = "red";
    }
  }
  else{
    document.getElementById("txt3").style.color = "red";
	sg.sound("error");
  }
}

var t4 = document.getElementById("txt4");
t4.addEventListener("keyup", verificar4); 

function verificar4(){
  var timer = null;
  clearTimeout(timer);
  timer = setTimeout(ver4, 10);
}

function ver4(){
  var cadena = " 180 ciento ochenta";
  var palabra = document.getElementById("txt4").value;
  if (cadena.indexOf(palabra) != -1){
	  document.getElementById("txt4").style.color = "black";
    if(palabra == "180" || palabra == "ciento 80"){
      document.getElementById("txt4").style.color = "green";
	  sg.sound("success-low");
	  sg.fadeOut('#img4');
	  sg.fadeIn('#img5');
      document.getElementById("txt4").disabled = true;
      document.getElementById("txt5").disabled = false;
	  document.getElementById("txt5").focus();
    }
    else{
    //  document.getElementById("txt4").style.color = "red";
    }
  }
  else{
    document.getElementById("txt4").style.color = "red";
	sg.sound("error");
  }
}

var t5 = document.getElementById("txt5");
t5.addEventListener("keyup", verificar5); 

function verificar5(){
  var timer = null;
  clearTimeout(timer);
  timer = setTimeout(ver5, 10);
}

function ver5(){
  var cadena = " hipotenusa ";
  var palabra = document.getElementById("txt5").value;
  if (cadena.indexOf(palabra) != -1){
	  document.getElementById("txt5").style.color = "black";
    if(palabra == "hipotenusa"){
      document.getElementById("txt5").style.color = "green";
	  sg.sound("success-low");
	  sg.fadeOut('#img5');
	  sg.fadeIn('#img6');
      document.getElementById("txt5").disabled = true;
      document.getElementById("txt6").disabled = false;
	  document.getElementById("txt6").focus();
    }
    else{
    //  document.getElementById("txt5").style.color = "red";
    }
  }
  else{
    document.getElementById("txt5").style.color = "red";
	sg.sound("error");
  }
}

var t6 = document.getElementById("txt6");
t6.addEventListener("keyup", verificar6); 

function verificar6(){
  var timer = null;
  clearTimeout(timer);
  timer = setTimeout(ver6, 10);
}

function ver6(){
  var cadena = " altura ";
  var palabra = document.getElementById("txt6").value;
  if (cadena.indexOf(palabra) != -1){
	  document.getElementById("txt6").style.color = "black";
    if(palabra == "altura"){
      document.getElementById("txt6").style.color = "green";
	  sg.sound("success-low");
	  sg.fadeOut('#img6');
	  sg.fadeIn('#img7');
      document.getElementById("txt6").disabled = true;
    }
    else{
    //  document.getElementById("txt6").style.color = "red";
    }
  }
  else{
    document.getElementById("txt6").style.color = "red";
	sg.sound("error");
  }
}

}
/*
function verificarRespuesta(){
	var resu1 = document.getElementById('txt1').value;
	if(resu1 == 3 || resu1 == "tres"){
		sg.sound('success');
		document.getElementById('txt1').style.color = "green";
		sg.fadeOut('#img1');
		sg.fadeIn('#img2');
		document.getElementById('txt1').disabled = true;
		}
		else{			
			document.getElementById('txt1').style.color = "red";
			sg.sound('error');
			}	
	}
	
function verificarRespuesta1(id){
	var resu2 = document.getElementById('txt2').value;	
	if(resu2 == 3 || resu2 == "tres"){
		sg.sound('success');
		document.getElementById('txt2').style.color = "green";
		sg.fadeOut('#img2');
		sg.fadeIn('#img3');		
		document.getElementById('txt2').disabled = true;
		}
		else{
			document.getElementById('txt2').style.color = "red";
			sg.sound('error');
			}
	}
	
function verificarRespuesta2(){
	var resu3 = document.getElementById('txt3').value;
	if(resu3 == 3 || resu3 == 'tres'){
		sg.sound('success');
		document.getElementById('txt3').style.color = "green";	
		sg.fadeOut('#img3');
		sg.fadeIn('#img4');
		document.getElementById('txt3').disabled = true;	
		}
		else{
			document.getElementById('txt3').style.color = "red";
			sg.sound('error');
			}		
	}

function verificarRespuesta3(){
	var resu3 = document.getElementById('txt4').value;
	if(resu3 == 180){
		sg.sound('success');
		document.getElementById('txt4').style.color = "green";
		sg.fadeOut('#img4');
		sg.fadeIn('#img5');
		document.getElementById('txt4').disabled = true;
		}
		else{
			document.getElementById('txt4').style.color = "red";
			sg.sound('error');
			}		
	}

function verificarRespuesta4(id){
	var resu2 = document.getElementById('txt5').value;	
	if(resu2 == 'hipotenusa' ){
		sg.sound('success');
		document.getElementById('txt5').style.color = "green";
		sg.fadeOut('#img5');
		sg.fadeIn('#img6');
		document.getElementById('txt5').disabled = true;
		}
		else{
			document.getElementById('txt5').style.color = "red";
			sg.sound('error');
			}
	}
	
function verificarRespuesta5(){
	var resu3 = document.getElementById('txt6').value;
	if(resu3 == 'altura' ){
		sg.sound('success');
		document.getElementById('txt6').style.color = "green";
		sg.fadeOut('#img6');
		sg.fadeIn('#img7');
		document.getElementById('txt6').disabled = true;
		}
		else{
			document.getElementById('txt6').style.color = "red";
			sg.sound('error');
			}	
	}
*/