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

function init() {
	document.addEventListener('keydown', bill, false);

	names = JSON.parse(localStorage.getItem('locnamepoint') || "[]");
	point = JSON.parse(localStorage.getItem('locpoint') || "[]");

}

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

var chars = ["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 newgameeasy() {
	document.getElementById('go').style.visibility = "hidden";
	document.getElementById('chars').style.visibility = "visible";
}

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

function newgamehard() {
	document.getElementById('go').style.visibility = "hidden";
	document.getElementById('chars').style.visibility = "visible";
}
function view() {
	document.getElementById('words').style.visibility = "visible";
	document.getElementById('now').style.visibility = "hidden";
	document.getElementById('add').style.visibility = "visible";
	document.getElementById('chars').style.visibility = "visible";
	document.getElementById('btn-hard-back').style.visibility = "visible";
}

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

function stop() {

	//document.querySelector("#startchar").innerHTML = ujbetu_r;
	clearInterval(myInterval);
	view();
	stopper();
	document.getElementById("words").focus();

}

var list = [];

var s = 0;
var z = 0;
function addarray() {

	var newitem = document.querySelector('#words').value
		if (jsoncheck() == true) {
			list.push(" " + newitem);
			document.querySelector("#array").innerHTML = list;
			s++;
			if(list.length%10==0){
				z = z + newitem.length + 10;
				utils.status.show('Bónusz 10 pont!');
			}else{
				z = z + newitem.length;
			}
		} else {
			utils.status.show('A szó nem létezik!');
			window.navigator.vibrate(200);
		}
		//document.querySelector("#array").innerHTML += list.length;
}

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

}

function check() {
	var ujbetu_r = document.getElementById("chars").innerHTML;
	var newitem = document.querySelector('#words').value;
	if (ujbetu_r == newitem[0]) {
		if (item() == true) {
			//document.body.style.background = "red";
			utils.status.show('Ezt már írtad!');
			window.navigator.vibrate(200);
			//document.querySelector(#words).style.color = "red";
			//setTimeout("document.body.style.background = '#e5dddd'", 500);
		} else {
			addarray();
			document.querySelector("#pontok").innerHTML = "Pontjaid : " + z;
		}
	} else {
		utils.status.show('Nem jó a kezdőbetű!');
		window.navigator.vibrate(200);
	}
	document.querySelector("#words").value = ('');

}

function jsoncheck() {
	var newitem = document.querySelector('#words').value;
	var hova = document.querySelector("#adatok");

	for (var key in JSONObject) {

		for (i = 0; i < JSONObject[key].length; i++) {
			if (JSONObject[key][i] == newitem)
				return true;
		}

	}
}

var hova = document.querySelector("#adatok");

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


}*/
