function check_fields(frm)
{
    for (i=1; i < arguments.length; i++) {
        if (frm[arguments[i]].value == '') {
            frm[arguments[i]].focus();
            alert('Vyplňte všechny položky označené hvězdičkou.');
            return false;
        }
    }
		return true;
}

function check_user(frm)
{
	var login, heslo, heslo1, pom=-1;
	for (i=1; i < arguments.length; i++) {
		switch (frm[arguments[i]].name) {
			case 'mLogin':login = frm[arguments[i]].value;
										pom = i;
										break;
 			case 'mHeslo': heslo = frm[arguments[i]].value; break;
 			case 'mHeslo1': heslo1 = frm[arguments[i]].value; break;
 			case 'mEmail': if (!zkontroluj_email(frm[arguments[i]].value)) {
											//alert ("Uživatel má špatně vyplněnou emailovou adresu.")
											return false;
										} break;

		}
		if (frm[arguments[i]].value == '') {
				frm[arguments[i]].focus();
				alert('Vyplňte všechny položky označené hvězdičkou.');
				return false;
		}
	}
	if (heslo != heslo1) {
		alert('Hesla se neshodují.');
 		return false;
 	}

//	alert('Hesla se neshodují. '+ heslo1 heslo);
	if (pom !=-1)frm[arguments[pom]].focus();
	var checker = document.createElement('script');
	checker.src = './include/login_exists.php?login='+login;
	document.getElementById('regform').appendChild(checker);
	return true;
}


function zkontroluj_email(adresa)
{
    re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
    result = adresa.search(re) == 0;
		if (!result) {
			alert ("Uživatel má špatně vyplněnou emailovou adresu.")
			return false;
		} else return true;
}

