var tela_pos = 0; // serve para identificar o posicionamento actual dentro de uma lista (popup list de pesquisas ajax) var tela_valor = ""; // serve para identificar se o valor actual é diferente do anterior após carregar numa tecla (popup list de pesquisas ajax) function mostrar_layer_login(accao) { do_splash(); myform = document.loginlayer; myform.accao.value = accao; larg = 450; alt = 200; alertSize(); obj = document.getElementById('layer_login'); var myLeft = (myWidth-larg)/2; var myTop = get_window_top()+150; //obj.style.left = myLeft; //obj.style.top = myTop; obj.style.visibility = "visible"; } function login_efectuar() { obj_wrap = document.getElementById('login_wrap'); objid_wrap = document.getElementById('loginid_wrap'); objid_nome = document.getElementById('loginid_nome'); // splash informativo do_splash(); do_aguarde(); username = document.login.username.value; password = document.login.password.value; lembrar = document.login.lembrar.checked; params = "username="+username+"&password="+password+"&lembrar="+lembrar; http.open("POST","lib/login.ajax.php",true); //Send the proper header information along with the request http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange=function() { if (http.readyState == 4) { results = http.responseText; tmp = results.split("<->"); erro_numero = tmp[0]; erro_str = tmp[1]; if (erro_numero=="1") { // esconde a div de login e mostra a de identificação document.getElementById('login_wrap').style.display = "none"; document.getElementById('loginid_wrap').style.display = "block"; document.getElementById('tela_aguarde_msg').style.visibility = "hidden"; document.getElementById('tela_aguarde').style.visibility = "hidden"; document.getElementById('splash').style.visibility = "hidden"; nome = tmp[2]; objid_nome.innerHTML = nome; } else { document.getElementById('login_wrap').style.display = "block"; document.getElementById('loginid_wrap').style.display = "none"; // login falhou bgcolor = "#7D2800"; imagem = "erro.png"; done = 0; if (erro_numero=="91") { botao = "document.login.username.focus();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="92") { botao = "document.login.password.focus();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="02") { botao = "document.login.username.focus();document.login.username.select();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="03") { botao = "document.login.username.focus();document.login.username.select();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="04") { botao = "document.login.password.focus();document.login.password.select();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (done==0) { botao = "document.login.username.focus();document.login.username.select();"; change_aguarde("ocorreu um erro não especificado!",bgcolor,imagem,botao); done = 1; } } } } http.send(params); } function loginlayer_efectuar() { obj = document.getElementById('layer_login'); obj.style.visibility = "hidden"; do_aguarde(); myform = document.loginlayer; username = myform.username.value; password = myform.password.value; accao = myform.accao.value; params = "username="+username+"&password="+password+"&lembrar=&accao="+accao; myajaxuid = getHTTPObject(); myajaxuid.open("POST","lib/login.ajax.php",true); //Send the proper header information along with the request myajaxuid.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); myajaxuid.setRequestHeader("Content-length", params.length); myajaxuid.setRequestHeader("Connection", "close"); myajaxuid.onreadystatechange=function() { if (myajaxuid.readyState == 4) { results = myajaxuid.responseText; tmp = results.split("<->"); obj.style.visibility = "visible"; erro_numero = tmp[0]; erro_str = tmp[1]; if (erro_numero=="1") { document.location.href="loginlayer.php?accao="+accao; } else { // login falhou bgcolor = "#7D2800"; imagem = "erro.png"; done = 0; if (erro_numero=="91") { botao = "myform.username.focus();"; change_aguarde(erro_str,bgcolor,imagem,botao,"1"); done = 1; } if (erro_numero=="92") { botao = "myform.password.focus();"; change_aguarde(erro_str,bgcolor,imagem,botao,"1"); done = 1; } if (erro_numero=="02") { botao = "myform.username.focus();myform.username.select();"; change_aguarde(erro_str,bgcolor,imagem,botao,"1"); done = 1; } if (erro_numero=="03") { botao = "myform.username.focus();myform.username.select();"; change_aguarde(erro_str,bgcolor,imagem,botao,"1"); done = 1; } if (erro_numero=="04") { botao = "myform.password.focus();myform.password.select();"; change_aguarde(erro_str,bgcolor,imagem,botao,"1"); done = 1; } if (done==0) { botao = "myform.username.focus();myform.username.select();"; change_aguarde("ocorreu um erro não especificado!",bgcolor,imagem,botao,"1"); done = 1; } } } } myajaxuid.send(params); } function do_registar(form) { // splash informativo do_splash(); do_aguarde(); // escreve uma iframe para submeter o formulário obj = document.getElementById('div_form_register'); obj.innerHTML = ""; form.target = "iframe_registar"; form.action = "lib/login-perfil.ajax.php"; form.submit(); } function loginnormal_efectuar() { obj_wrap = document.getElementById('login_wrap'); // splash informativo do_splash(); do_aguarde(); username = document.login.username.value; password = document.login.password.value; lembrar = document.login.lembrar.checked; params = "username="+username+"&password="+password+"&lembrar="+lembrar; http.open("POST","lib/login.ajax.php",true); //Send the proper header information along with the request http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange=function() { if (http.readyState == 4) { results = http.responseText; tmp = results.split("<->"); erro_numero = tmp[0]; erro_str = tmp[1]; if (erro_numero=="1") { // reencaminha // reencaminha para o página inicial do utilizador document.location.href="conteudo.php?pag=home&lingua=pt"; } else { // login falhou bgcolor = "#7D2800"; imagem = "erro.png"; done = 0; if (erro_numero=="91") { botao = "document.login.username.focus();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="92") { botao = "document.login.password.focus();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="02") { botao = "document.login.username.focus();document.login.username.select();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="03") { botao = "document.login.username.focus();document.login.username.select();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (erro_numero=="04") { botao = "document.login.password.focus();document.login.password.select();"; change_aguarde(erro_str,bgcolor,imagem,botao); done = 1; } if (done==0) { botao = "document.login.username.focus();document.login.username.select();"; change_aguarde("ocorreu um erro não especificado!",bgcolor,imagem,botao); done = 1; } } } } http.send(params); } function reencaminhar_home() { window.parent.document.location.href="index.php"; } function pesq_destinatarios(valor,id) { if (valor!="") { myajax_msg = getHTTPObject(); myajax_msg.open("GET","ajax/pesq_destinatarios.php?campo=document.msg_redigir.destinatario&procura="+valor,true); myajax_msg.onreadystatechange=function() { if (myajax_msg.readyState == 4) { results = myajax_msg.responseText; if (results!="") { document.getElementById('divdestinatarios_ajax').innerHTML = results; document.getElementById('divdestinatarios_ajax').style.visibility = "visible"; } else { document.getElementById('divdestinatarios_ajax').innerHTML = ""; document.getElementById('divdestinatarios_ajax').style.visibility = "hidden"; } } } myajax_msg.send(null); } else { document.getElementById('divdestinatarios_ajax').innerHTML = ""; document.getElementById('divdestinatarios_ajax').style.visibility = "hidden"; } } function add_destinatario(valor,id) { campo = document.msg_redigir.destinatario; campo1 = document.msg_redigir.destinatarios_sel; campo2 = document.msg_redigir.destinatarios_sellabels; obj = document.getElementById('divdestinatarios_ajax'); obj1 = document.getElementById('msg_destinatarios_labels'); obj.innerHTML = ""; obj.style.visibility = "hidden"; campo.value = ""; ids = campo1.value; verifica = destinatario_verifica(ids,id); if (verifica==0) { if (ids!="") { campo1.value = campo1.value+","+id; campo2.value = campo2.value+","+valor; } else { campo1.value = id; campo2.value = valor; } obj1.innerHTML = obj1.innerHTML + "