var nrord1=0;
var total=0;
var n=15;
var prop= new Array("fools rush in where angels fear to tread","two is company three is a crowd","those who live in glass houses should not throw stones","the early bird catches the worm","laughter is the best medicine","good fences make good neighbors","blood is thicker than water","an apple a day keeps the doctor away");
var trad=new Array("Prostii se reped acolo unde ingerii nu calca","Doi oameni inseamna tovarasie trei inseamna imbulzeala","Cei ce locuiesc in case de sticla sa nu dea cu pietre", "Pasarea venita prima prinde viermele","Rasul este cel mai bun medicament","Gardurile bune ii fac pe vecini prieteni","Sangele apa nu se face","Un mar pe zi tine doctorul departe")
var prp=""
var trd=""
var tot=0
var cntval=0
var nrcrt=0
var prvb=""
var str="<table border='0'><tr>"
var alfabet = new Array();
var crtclr= new Array();
var ord0 = new Array();
var ord1 = 0;
var culori = new Array("red","blue","green","yellow","gold","magenta","cyan","navy","orange","pink","seashell","tan","silver","maroon","lime","blueviolet","lightsteelblue","deeppink","darkolivegreen","gray","turquoise","cornflowerblue","powderblue","brown","navajowhite","black")
var exercitii=new Array("I'm the thinnest of them all","All babies love me","I spin when boiled","Do dentists love me or hate me?","I inspired Issac Newton","Photographers like me, for some reason.","I have taste!","A-choo!","I keep the world alive","My name says it all","Don't be me!","I don't like squirrels.","I make muscles bulge, in cartoons","We are all twins.","I am here now, be sure of that.")
var raspuns=new Array("spaghetti","milk","egg","candy","apple","cheese","salt","pepper","water","popcorn","toast","walnut","spinach","peas","beans")
var keynum="";

function count(param){
prp=prop[param]
prvb=param;
trd=trad[param]
for (i=0;i<n+1;i++){ 
ord0[i]=0;
}
for (i=0;i<26;i++){
	alfabet[i]=0
}
for (i=0;i<prp.length;i++){
	str=str+"<td id='td"+i+"'style='width:20px; height:20px;'>"+"</td>"
}
str=str+"</tr><table>"
document.getElementById("cont").innerHTML=str
for (i=0;i<prp.length;i++){
	if (alfabet[prp.charCodeAt(i)-97]==0){
	crtclr[nrcrt]=culori[prp.charCodeAt(i)-97]
	nrcrt=nrcrt+1
	}
alfabet[prp.charCodeAt(i)-97]=alfabet[prp.charCodeAt(i)-97]+1;
document.getElementById("td"+i).style.backgroundColor=culori[prp.charCodeAt(i)-97]
}
for (i=0;i<26;i++){
		if (alfabet[i]!=0){
		tot=tot+1
	}
}
//for(i=1;i<4;i++){
//	for(j=1;j<6;j++){
//	var sir="pos"+i+j
//	var nrvar=5*(i-1)+j-1;
//	document.getElementById(sir).innerHTML=raspuns[nrvar]
//		}
//}
ord1=Math.floor(Math.random()*n);
var tnr="ttd"+ord1;
document.getElementById("ex").innerHTML="<h1>"+document.getElementById(tnr).innerHTML+"</h1>"

}
function check(nrcell){
	if (total<15){
		cntval=cntval+1
		var nrcell1=Math.floor(nrcell/5)+1
		var nrcell2=nrcell-(nrcell1-1)*5+1
		if (ord1==nrcell){
			document.getElementById("pos"+nrcell1+nrcell2).style.backgroundColor="green"
			for (i=0;i<prp.length;i++){
			
			if (document.getElementById("td"+i).style.backgroundColor==crtclr[nrcell]){
			document.getElementById("td"+i).style.backgroundColor="white"
			document.getElementById("td"+i).innerHTML=prp.substr(i,1)
				}
		}
			total=total+1
			ord0[ord1]=1
		}else{
				document.getElementById("pos"+nrcell1+nrcell2).style.backgroundColor="red"
		}
	if (total<15){
		ord1=Math.floor(Math.random()*n);
	while(ord0[ord1]==1){
	ord1=Math.floor(Math.random()*n)
	}
	var tnr="ttd"+ord1;
document.getElementById("ex").innerHTML="<h1>"+document.getElementById(tnr).innerHTML+"</h1>"

		}else if (total==15){
	document.getElementById("rom").innerHTML="<h2>"+trd+"</h2>"
	document.getElementById("all1").style.visibility="hidden";	
				var vallist=0;
		try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
		} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			vallist=ajaxRequest.responseText
				}
	}	
	var engleza = prvb;
    var queryString = "?engleza=" + escape(engleza);
	ajaxRequest.open("GET", "makecookie.php"+queryString, true);
	ajaxRequest.send(null); 
	
		}
}
}
function expl(){
	alert("Acest joc se schimba zilnic. Daca stii la ce se refera explicatia de sus vei intelege si ce iti spune invatatul Girolamo. Traducerea iti este deasemeni oferita. Invatatul Girolamo iti da tie personal un sfat pentru aceasta zi. Daca stii ce vrea sa-ti spuna inainte de a termina jocul scrie raspunsul ... poate poti si tu sa devii filozof. Scrie daca ai curaj...")
}
function verifica(e){
	if(window.event) // IE
  {
  keynum = e.keyCode;
  }
else if(e.which) // Netscape/Firefox/Opera
  {
  keynum = e.which;
  }
  if (keynum==13){
	var vrf=document.getElementById("txt").value
	if (vrf.toLowerCase()==prp){
		document.getElementById("winner").style.visibility="visible";
			}else{
	alert("Vazut-am noi si alte dati pe-aici zevzeci ca tine")
		}
}
}
function afiseaza(){
	document.getElementById("winner").style.visibility="hidden";
	document.getElementById("intelepti").style.visibility="visible";
	document.getElementById("numenou").innerHTML=document.getElementById("numelemeu").value
	document.getElementById("nrnou").innerHTML=cntval
			var vallist=0;
		try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
		} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			vallist=ajaxRequest.responseText
				}
	}	
	var engleza1 = cntval;
	var engleza2 =document.getElementById("numelemeu").value;
	var engleza3 = prvb;
    var queryString = "?engleza1=" + escape(engleza1)+"&engleza2="+escape(engleza2)+"&engleza3="+escape(engleza3);
	ajaxRequest.open("GET", "listajoczilnic.php"+queryString, true);
	ajaxRequest.send(null); 
}
function topazi(){
document.getElementById("intelepti").style.visibility="visible";
	}
function topvechi(){
document.getElementById("intelepti").style.visibility="visible";
	}
function inchide(){
document.getElementById("intelepti").style.visibility="hidden";	
	}
function datele(){
	document.getElementById("winner").style.visibility="hidden";
	
}
