// JavaScript Document
function checkFrmRegister(form)
{
	with (form) {
		if (!valida_user_senha(txtUserName)) {
			return false;
		} else if (!valida_user_senha(txtPassword)) {
			return false;
		} else if (txtPassword.value != txtPassword2.value) {
			alert('A duas senhas digitadas não conferem !');
			txtPassword2.focus();
			return false;
		} else if (isEmpty(txtName, 'Entre com o nome completo do usuário')) {
			return false;
		} else if (isEmpty(txtEmail, 'Entre com o email do usuário')) {
			return false;
		} else if (!checkMail(txtEmail)) {
			return false;
		} else if (!check_radio(afiliado)) {
			alert ("Marque a opção se é afiliado ou não");
			return false;
		} else {
			return true;
		}
	}
}

function checkFrmModify(form)
{
	with (form) {
		if (isEmpty(txtName, 'Entre com o nome completo do usuário')) {
			return false;
		} else if (isEmpty(txtEmail, 'Entre com o email do usuário')) {
			return false;
		} else if (!checkMail(txtEmail)) {
			return false;
		} else if (!check_radio(afiliado)) {
			alert ("Marque a opção se é afiliado ou não");
			return false;
		} else {
			return true;
			
		}
	}
}

function checkFrmRecover(form)
{
	with (form) {
		if (isEmpty(recEmail, 'Entre com o seu email')) {
			return false;
		} else if (!checkMail(recEmail)) {
			return false;
		} else if (!check_radio(recType)) {
			alert ("Escolha o que deseja recuperar !");
			return false;
		} else {
			return true;
			
		}
	}
}

function addUser()
{
	window.location.href = 'index.php?view=add';
}

function changeUser(userId)
{
	window.location.href = 'index.php?view=modify&userId=' + userId;
}

function deleteUser(userId)
{
	if (confirm('Apagar este usuário?')) {
		window.location.href = 'processUser.php?action=delete&userId=' + userId;
	}
}