function $(id){
	return document.getElementById(id);
}

function init(){

	

	document.addEventListener('keydown', bill, false);
	document.getElementById('charseasy').style.visibility = "visible";
	
	names = JSON.parse(localStorage.getItem('locnamepoint') || "[]");
	point = JSON.parse(localStorage.getItem('locpoint') || "[]");
	
}

window.addEventListener('load', init, false);

var charseasy = ["a","á","b","c","d","e","é","f","g","h","i","í","j","k","l","m","n","o","ó","ö","ő","p","q","r","s","t","u","ú","ü","ű","v","w","x","y","z"];





function bill(e){
	
	if (e.type === 'keydown'){
		if (e.keyCode === 13){
			if(document.querySelector('#easy').className == 'current'){
				checkeasy();
			}else if(document.querySelector('#hard').className == 'current'){
				check();
			}
		}
	}
}

function newgamemedium(){
	document.getElementById('go').style.visibility = "hidden";
	document.getElementById('charseasy').style.visibility = "visible";
}

function newgamehard(){
	document.getElementById('go').style.visibility = "hidden";
	document.getElementById('charseasy').style.visibility = "visible";
}
function vieweasy(){
	document.getElementById('wordseasy').style.visibility = "visible";
	document.getElementById('noweasy').style.visibility = "hidden";
	document.getElementById('addeasy').style.visibility = "visible";
	document.getElementById('charseasy').style.visibility = "visible";
	document.getElementById('btn-easy-back').style.visibility = "visible";
}
function viewnot(){
	document.getElementById('go').style.visibility = "hidden";
	document.getElementById('charseasy').style.visibility = "visible";
}
var i=0;

function charmove(){
	
	
	if(i<charseasy.length){
		document.getElementById("charseasy").innerHTML=charseasy[i];
		i++;
		}else{
		i=0;
		}
	
}



/*function randValaszt(tomb){
	var index = Math.floor(Math.random() * tomb.length);
	var ujbetu;
	ujbetu_r=tomb[index];
	return tomb[index];
}
var onechar = randValaszt(charseasy);

function randchar(){
		var onechar = randValaszt(charseasy);
        var charseasyDiv = document.querySelector('#charseasy');
        charseasyDiv.innerHTML = '<p>'+onechar+'</p>';
}
*/


function stopeasy(){
	clearInterval(myIntervaleasy);
	vieweasy();
	stoppereasy();
}

var list = [];

var s=0;
var z=0;
function addarrayeasy(){
	
	var newitem = document.querySelector('#wordseasy').value
	if(jsoncheckeasy() == true){
	list.push(newitem);
	document.querySelector("#arrayeasy").innerHTML = list;
	s++;
	z=z+newitem.length;
	}else{
		utils.status.show('A szó nem létezik!');
	}
	//document.querySelector("#arrayeasy").innerHTML += list.length;
}


function itemeasy(i){
	var newitem = document.querySelector('#wordseasy').value;
	for(var i=0; i<list.length; i++){
			if(list[i]==newitem) return true;
		}
		
}


function checkeasy(){
	var ujbetu_r = document.getElementById("charseasy").innerHTML;
	var newitem = document.querySelector('#wordseasy').value;
	if(ujbetu_r == newitem[0]){
		if(	itemeasy() == true ){
			utils.status.show('Ezt már írtad!');
		}else{
		addarrayeasy();
		document.querySelector("#pontokeasy").innerHTML = "pontjaid : "+z;
		}
	}else{
		utils.status.show('Nem jó a kezdőbetű!');
	}
	document.querySelector("#wordseasy").value = ('');
	
}

function jsoncheckeasy(){
var newitem = document.querySelector('#wordseasy').value;
var hova = document.querySelector("#adatokeasy");
	for(var key in JSONObject)     {
		
		for(i=0;i<JSONObject[key].length;i++) {
			if(JSONObject[key][i]==newitem) return true;
		}
	
	}
}

function jsoneasy(){
var hova = document.querySelector("#adatokeasy");
hova.innerHTML = '<h3 style="text-align:center;">A tömb adatai<\/h3><hr \/>';
//A behívott fáljban lévő "JSONObject" tartalmaának megjelenítési folyamata
for(var key in JSONObject)                              //lekéri a kulcsot
{
  if($.isarray(JSONObject[key]))                        //ha a kulcshoz tartozó tartalom tömb...
  {
    for(i=0;i<JSONObject[key].length;i++)               //végig megy a tömbön
    {
      $.each(JSONObject[key][i], function(key1, value1) //lekéri és megjeleníti a belső tömb kulcsát és tartalmát
      {
        hova.innerHTML += ""+key1+": <span>" +value1+"</span><br \/>";
      });
	    hova.innerHTML += "<hr \/>";
    }
  }
  else                                                  //ha a kulcshoz tartozó tartalom NEM tömb...
  {                                                     //megjeleníti a tömb kulcsát és tartalmát
    hova.innerHTML += ""+key+": <span>" +JSONObject[key]+"</span><br \/>";
	  hova.innerHTML += "<hr \/>";
  }
}
}

/*function vegeeasy(){
	document.getElementById('wordseasy').style.visibility = "hidden";
	document.getElementById('addeasy').style.visibility = "hidden";
	document.getElementById('btn-easy-back').style.visibility = "hidden";
	
	var nev = prompt('Neved:',"Neved?")
	names.push(nev);
	//console.log(nev);
	
	var data1 = z;
	point.push(data1);
	
	localStorage.setItem('locpoint', JSON.stringify(point));  
	localStorage.setItem('locnamepoint', JSON.stringify(names));
	
	
	
	
	
	//window.location.assign("top.html");
}*/



	
/*function newgame(){
	function randchar(){
		var onechar = charseasy[Math.floor(Math.random()*charseasy.length)];
	};
	document.getElementById("charseasy").innerHTML = charseasy;
	setInterval(function randchar(), 3000);
	
	
}*/