function kontrola_mailu(mail) {
	
	mailv = mail.value;
	
	if(mailv.indexOf('@')>0 && mailv.indexOf('.')>=11) {
		document.getElementById('kontrola_mailu').innerHTML='<span class=\"lime\">E-mail je OK!</span>';
		return true;
	}
	else {
		document.getElementById('kontrola_mailu').innerHTML='<span class=\"red\">Nesprávny formát e-mailu!</span>';
		return false;
	}
	
}



function sila_hesla(heslo) {
	
	var new_heslo;
	new_heslo = heslo.value;
	
	if(new_heslo.length<4) {
		document.getElementById('sila_hesla').innerHTML='<span class=\"red\">Heslo musí mať minimálne 4 znaky!</span>';
	}
	if(new_heslo.length==4) {
		document.getElementById('sila_hesla').innerHTML='<span class=\"red\">Veľmi slabé heslo!</span>';
	}
	if((new_heslo.length>4 && new_heslo.length<8) && (new_heslo.indexOf(0)<0 || new_heslo.indexOf(1)<0 || new_heslo.indexOf(2)<0 || new_heslo.indexOf(3)<0 || new_heslo.indexOf(4)<0 || new_heslo.indexOf(5)<0 || new_heslo.indexOf(6)<0 || new_heslo.indexOf(7)<0 || new_heslo.indexOf(8)<0 || new_heslo.indexOf(9)<0)) {
		document.getElementById('sila_hesla').innerHTML='<span class=\"red\">Slabé heslo!</span>';
	}
	if((new_heslo.length>5 && new_heslo.length<10) && (new_heslo.indexOf(0)>0 || new_heslo.indexOf(1)>0 || new_heslo.indexOf(2)>0 || new_heslo.indexOf(3)>0 || new_heslo.indexOf(4)>0 || new_heslo.indexOf(5)>0 || new_heslo.indexOf(6)>0 || new_heslo.indexOf(7)>0 || new_heslo.indexOf(8)>0 || new_heslo.indexOf(9)>0)) {
		document.getElementById('sila_hesla').innerHTML='<span class=\"lime\">Dobré heslo!</span>';
	}
	if((new_heslo.length>5 && new_heslo.length<12) && (new_heslo.indexOf(0)>0 || new_heslo.indexOf(1)>0 || new_heslo.indexOf(2)>0 || new_heslo.indexOf(3)>0 || new_heslo.indexOf(4)>0 || new_heslo.indexOf(5)>0 || new_heslo.indexOf(6)>0 || new_heslo.indexOf(7)>0 || new_heslo.indexOf(8)>0 || new_heslo.indexOf(9)>0) && (new_heslo.indexOf('-')>0 || new_heslo.indexOf('*')>0 || new_heslo.indexOf('/')>0 || new_heslo.indexOf('@')>0 || new_heslo.indexOf('$')>0 || new_heslo.indexOf('/')>0 || new_heslo.indexOf('&')>0 || new_heslo.indexOf('^')>0 || new_heslo.indexOf('+')>0 || new_heslo.indexOf('~')>0)) {
		document.getElementById('sila_hesla').innerHTML='<span class=\"lime\">Kvalitné heslo!</span>';
	}
	if((new_heslo.length>5 && new_heslo.length<150) && (new_heslo.indexOf(0)>0 || new_heslo.indexOf(1)>0 || new_heslo.indexOf(2)>0 || new_heslo.indexOf(3)>0 || new_heslo.indexOf(4)>0 || new_heslo.indexOf(5)>0 || new_heslo.indexOf(6)>0 || new_heslo.indexOf(7)>0 || new_heslo.indexOf(8)>0 || new_heslo.indexOf(9)>0) && (new_heslo.indexOf('-')>0 || new_heslo.indexOf('*')>0 || new_heslo.indexOf('/')>0 || new_heslo.indexOf('@')>0 || new_heslo.indexOf('$')>0 || new_heslo.indexOf('/')>0 || new_heslo.indexOf('&')>0 || new_heslo.indexOf('^')>0 || new_heslo.indexOf('+')>0 || new_heslo.indexOf('~')>0)) {
		document.getElementById('sila_hesla').innerHTML='<span class=\"lime\">Perfektné heslo!</span>';
	}
	
}

function zhoda_hesla(heslo1, heslo2) {
	
	w_heslo1 = heslo1.value;
	w_heslo2 = heslo2.value;
	
	if(w_heslo1==w_heslo2) {
		document.getElementById('zhoda_hesla').innerHTML='<span class=\"lime\">Heslá sa zhodujú!</span>';
	}
	else {
		document.getElementById('zhoda_hesla').innerHTML='<span class=\"red\">Heslá sa nezhodujú!</span>';
	}
	
}

function over_prihl_meno(hodnota2) {
	
	hodnota = hodnota2.value;
	
	if(hodnota!="" && hodnota!=" ") {
		
		if(XMLHttpRequestObjekt) {
			
			XMLHttpRequestObjekt.open("POST", "./ajax/over_prihlasovacie_meno/over_registracia.php");
			XMLHttpRequestObjekt.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			
			XMLHttpRequestObjekt.onreadystatechange = function() {
				
				if(XMLHttpRequestObjekt.readyState == 4 && XMLHttpRequestObjekt.status == 200) {
					
					document.getElementById('nick_reg').innerHTML=XMLHttpRequestObjekt.responseText;

				}
				
			}
			
			XMLHttpRequestObjekt.send("hodnota="+hodnota);
			
		}
	
	}
	
}
