function md5_pwd() {
showMsg('Aguarde...')
tmp1=document.getElementById('loginSenha').value
if (tmp1=='') return;
tmp=hex_md5(tmp1)
document.getElementById('loginSenha').value=tmp
}

function validaLogin(){
if ((document.getElementById('loginSenha').value!='')&&(document.getElementById('loginEmail').value!=''))
document.getElementById('loginbt').disabled=false 
else
document.getElementById('loginbt').disabled=true 
}

function checar_caps_lock(ev) {
	// onkeypress="checar_caps_lock(event)"
	var e = ev || window.event;
	codigo_tecla = e.keyCode?e.keyCode:e.which;
	if ((codigo_tecla==13)&&(!document.getElementById('loginbt').disabled)) {
		md5_pwd(); 
		sendData('loginForm',local+'anuncios/login','xml');
		return
	}
	
	tecla_shift = e.shiftKey?e.shiftKey:((codigo_tecla == 16)?true:false);
	if(((codigo_tecla >= 65 && codigo_tecla <= 90) && !tecla_shift) || ((codigo_tecla >= 97 && codigo_tecla <= 122) && tecla_shift)) {
		showMsg('<b>Caps Lock ativado.</b>')
		//return true;
	}
	else {
		//return false;
		showMsg('')
	}
}


function login(){
	var handleSubmit = {
		success:function( args){
			ret=args.responseText
			if (ret=='e') showMsg('Dados inválidos <a href="'+local+'ajuda/ajuda.php?topico=dadosInvalidos"  class="quest"></a>')
			if (ret=='i') showMsg('Cadastro Inativo <a href="'+local+'ajuda/ajuda.php?topico=cadastroInativo" class="quest"></a>')
			if (ret=='p') showMsg('Preencha corretamente os campos')
			if (ret=='o') window.open(local+'anuncios/index.php','_self')
			if (ret.charAt(0)=='m') window.open(local+'anuncios/termos.php?'+ret,'_self');
		},
		failure:function( args){
			alert(args.responseText)
		}
	};
	YAHOO.util.Connect.setForm('loginForm', false);
	YAHOO.util.Connect.asyncRequest('POST', local+'anuncios/login.php', handleSubmit);
	document.getElementById('loginSenha').value='';
/*
i- inativo
m-termos
o-Ok
e - dados inválidos
p - email/senha faltando
*/
}
