ico_alerta = '<img src="images/ico_alerta.gif" alt="" width="24" height="24" style="padding:0 3px 0 0;vertical-align:middle" /> ';
ico_erro = '<img src="images/ico_error.gif" alt="" width="24" height="24" style="padding:0 3px 0 0;vertical-align:middle" /> ';
ico_carregando = '<img src="images/carregando.gif" alt="" width="16" height="16" style="padding:0 3px 0 0;vertical-align:middle" /> ';
msgajuda = ico_alerta + ' Entre seu e-mail e senha, para ter acesso a sua conta';
function checkemail(varEmail){var str=varEmail;var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if (filter.test(str))testresults=true;else{testresults=false}return (testresults)}
function iniciarLogin(){
	f = document.forms[0];
	var logado_var = "0";
	var email_var = "";
	var codigo_var = "";
	var senha_var = "";
	var senha2_var = "";
	var usercode_var = "";
	var tipologin_var = escape(f.tipologin.value);
	var cuser_var = escape(f.cuser.value);
	if(f.email){
		email_var = escape(f.email.value);
	}
	if(f.codigo){
		codigo_var = escape(f.codigo.value);
	}
	if(f.senha){
		senha_var = escape(f.senha.value);
	}
	if(f.senha2){
		senha2_var = escape(f.senha2.value);
	}
	aviso = false;

	tipologin_id = document.getElementById('tipologin');
	caixalogado_id = document.getElementById('caixalogado');
	caixalogin_id = document.getElementById('caixalogin');
	caixaimgcodigo_id = document.getElementById("caixaimgcodigo");
	tsenha_id = document.getElementById("tsenha");
	isenha_id = document.getElementById("isenha");
	if(document.getElementById("tsenha2")){
		tsenha2_id = document.getElementById("tsenha2");
	}
	if(document.getElementById("isenha2")){
		isenha2_id = document.getElementById("isenha2");
	}
	ichkbox_id = document.getElementById("ichkbox");
	tlogado_id = document.getElementById("tlogado");
	botaologin_id = document.getElementById("botaologin");
	linklogin1_id = document.getElementById("linklogin1");
	//linklogin2_id = document.getElementById("linklogin2");

	if(document.getElementById('logado')){
		logado_id = document.getElementById('logado');
		if(logado_id.checked){
			logado_var = "1";
		}
		else{
			logado_var = "0";
		}
	}
	if(!checkemail(email_var)){
		Tip(ico_alerta + 'e-mail inv&aacute;lido',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.email.focus();
	}
	else if(tipologin_var==0 && senha_var == ""){
		Tip(ico_alerta + 'Preencha a senha',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.senha.value="";
		f.senha.focus();
	}
	else if(((tipologin_var > 0 && tipologin_var <= 4) || tipologin_var == 6 || tipologin_var == 7) && codigo_var == ""){
		Tip(ico_alerta + 'Preencha o c&oacute;digo da imagem',BALLOON,true,ABOVE,false,FIX,['codigo', 0, -8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.codigo.value="";
		f.codigo.focus();
	}
	else if(tipologin_var == "5" && senha_var == ""){
		Tip(ico_alerta + 'Preencha a nova senha',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.senha.value="";
		f.senha.focus();
	}
	else if(tipologin_var == "5" && senha_var.length < 6){
		Tip(ico_alerta + 'A nova senha deve ter pelo menos 6 caracteres',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.senha.value="";
		f.senha.focus();
	}
	else if(tipologin_var == "5" && senha2_var == ""){
		Tip(ico_alerta + 'Confirme a nova senha',BALLOON,true,ABOVE,true,FIX,['senha2', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.senha2.value="";
		f.senha2.focus();
	}
	else if(tipologin_var == "5" && (senha_var != senha2_var)){
		Tip(ico_alerta + 'As senhas n&atilde;o confirmam<br /><br />Tente novamente',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
		f.senha.value="";
		f.senha2.value="";
		f.senha.focus();
	}
	else{
		var http=getXMLHTTPRequest();
		if(http){
			var params = "email=" + email_var;
			if(tipologin_var=="0"){
				params+= "&logado=" + logado_var;
				params+= "&senha=" + senha_var;
			}
			else if((tipologin_var > 0 && tipologin_var <= 4) || tipologin_var == 6 || tipologin_var == 7){
				params+= "&codigo=" + codigo_var;
				params+= "&tipo=" + tipologin_var;
				params+= "&cuser=" + cuser_var;
			}
			else if(tipologin_var == "5"){
				params+= "&tipo=" + tipologin_var;
				params+= "&senha=" + senha_var;
				params+= "&senha2=" + senha2_var;
				params+= "&cuser=" + cuser_var;
			}

			if(tipologin_var=="0"){
				Tip('logando... '+ico_carregando,ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			}
			else{
				Tip('enviando... '+ico_carregando,ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			}

			if(tipologin_var=="0"){
				http.open("POST", "includes/vLogin.php?"+Math.random(), true);
			}
			else if(tipologin_var > 0 && tipologin_var <= 4){
				http.open("POST", "includes/vCheck.php?"+Math.random(), true);
			}
			else if(tipologin_var == "5"){
				http.open("POST", "includes/vEsqueci.php?"+Math.random(), true);
			}
			else if(tipologin_var == "6" || tipologin_var == "7"){
				http.open("POST", "includes/vAtivar.php?"+Math.random(), true);
			}
			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){
					if(http.status == 200){
						if(tipologin_var=="0"){
							processXMLvLogin(http.responseXML);
						}
						else if(tipologin_var > 0 && tipologin_var <= 4){
							processXMLvCheck(http.responseXML);
						}
						else if(tipologin_var == "5"){
							processXMLvEsqueci(http.responseXML);
						}
						else if(tipologin_var == "6" || tipologin_var == "7"){
							processXMLvAtivar(http.responseXML);
						}
					}
					else{
						if(tipologin_var=="0"){
							Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[02]<br />erro ao tentar acessar os dados no servidor',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
						}
						else{
							Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[02b]<br />erro ao tentar acessar os dados no servidor',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
						}
					}
				}
			};
			http.send(params);
		}
		else{
			Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[01]<br />erro XMLHttpRequest',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
	}
	return false;
}
function processXMLvLogin(obj){
	var dataArray = obj.getElementsByTagName("statuslogin");
	if(dataArray.length == 1) {
		var item = dataArray[0];
		var status_xml = item.getElementsByTagName("status_xml")[0].firstChild.nodeValue;
		var msgerro_xml = item.getElementsByTagName("msgerro_xml")[0].firstChild.nodeValue;
		var imgcodigo_xml = item.getElementsByTagName("imgcodigo_xml")[0].firstChild.nodeValue;
		var titulo_xml = item.getElementsByTagName("titulo_xml")[0].firstChild.nodeValue;
		var input_xml = item.getElementsByTagName("input_xml")[0].firstChild.nodeValue;
		var botao_xml = item.getElementsByTagName("botao_xml")[0].firstChild.nodeValue;
		var link_xml = item.getElementsByTagName("link_xml")[0].firstChild.nodeValue;
		var tipologin_xml = item.getElementsByTagName("tipologin_xml")[0].firstChild.nodeValue;
		var diretorio_xml = item.getElementsByTagName("diretorio_xml")[0].firstChild.nodeValue;
		var conteudo_xml = item.getElementsByTagName("conteudo_xml")[0].firstChild.nodeValue;

		if(status_xml==1){
			Tip(ico_alerta + 'e-mail inv&aacute;lido',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==2){
			Tip(ico_alerta + 'Preencha a senha',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==3){
			Tip(ico_alerta + 'Login inv&aacute;lido<br />tente novamente...',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.email.value="";
			f.senha.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==4 || status_xml==5 || status_xml==6 || status_xml==9){
			msgajuda = ico_alerta + msgerro_xml;
			Tip(ico_alerta + msgerro_xml,ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);

			caixaimgcodigo_id.style.display = "";
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			tsenha_id.innerHTML = titulo_xml;
			isenha_id.innerHTML = input_xml;

			ichkbox_id.innerHTML = "&nbsp;";
			tlogado_id.innerHTML = "&nbsp;";
			botaologin_id.innerHTML = botao_xml;
			linklogin1_id.innerHTML = link_xml;
			//linklogin2_id.style.display = "none";
			tipologin_id.value = tipologin_xml;
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==7){
			Tip(ico_alerta + 'Sistema em manuten&ccedil;&atilde;o!',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			f.email.value="";
			f.senha.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==8){
			Tip(ico_alerta + 'e-mail ou senha inv&aacute;lida<br />tente novamente...',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha.value="";
			window.setTimeout("f.senha.focus();",10);
		}
		else if(status_xml==10){
			top.document.location.href = "./"+diretorio_xml;
		}
		else if(status_xml==11){
			caixalogin_id.innerHTML = "&nbsp;";
			caixalogin_id.style.display = "none";
			caixalogado_id.style.display = "";
			caixalogado_id.innerHTML = conteudo_xml;
			UnTip();
		}
		else{
			Tip(ico_erro + 'Erro parametro n&atilde;o definido...',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
function processXMLvCheck(obj){
	var dataArray = obj.getElementsByTagName("statuslogin");

	if(dataArray.length == 1){
		var item = dataArray[0];
		var status_xml = item.getElementsByTagName("status_xml")[0].firstChild.nodeValue;
		var imgcodigo_xml = item.getElementsByTagName("imgcodigo_xml")[0].firstChild.nodeValue;
		var mensagem_xml = item.getElementsByTagName("mensagem_xml")[0].firstChild.nodeValue;
		var debug = item.getElementsByTagName("debug")[0].firstChild.nodeValue;

		if(status_xml==1){
			Tip(ico_alerta + 'e-mail inv&aacute;lido',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==2){
			Tip(ico_alerta + 'c&oacute;digo inv&aacute;lido',BALLOON,true,ABOVE,false,FIX,['codigo', 0, -8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==3){
			Tip(ico_alerta + 'Login inv&aacute;lido<br />tente novamente...',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.email.value="";
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==4){
			Tip(ico_alerta + 'Erro ao tentar atualizar a base<br />tente novamente...',BALLOON,true,ABOVE,false,FIX,['codigo', 0, -8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==5){
			Tip(ico_alerta + 'Erro ao tentar enviar o e-mail<br />tente novamente...',BALLOON,true,ABOVE,false,FIX,['codigo', 0, -8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==6){
			msgajuda = ico_alerta + mensagem_xml;
			Tip(ico_alerta + mensagem_xml,ABOVE,true,FIX,['email', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			tipologin_id.value = 4;
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==0){
			window.setTimeout("voltar('"+mensagem_xml+"');",10);
		}
		else{
			Tip(ico_erro + 'Erro parametro n&atilde;o definido...',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
function processXMLvEsqueci(obj){
	var dataArray = obj.getElementsByTagName("statuslogin");

	if(dataArray.length == 1){
		var item = dataArray[0];
		var status_xml = item.getElementsByTagName("status_xml")[0].firstChild.nodeValue;
		var msg_xml = item.getElementsByTagName("msg_xml")[0].firstChild.nodeValue;
		var imgcodigo_xml = item.getElementsByTagName("imgcodigo_xml")[0].firstChild.nodeValue;
		var titulo_xml = item.getElementsByTagName("titulo_xml")[0].firstChild.nodeValue;
		var input_xml = item.getElementsByTagName("input_xml")[0].firstChild.nodeValue;
		var tipo_xml = item.getElementsByTagName("tipo_xml")[0].firstChild.nodeValue;
		var conteudo_xml = item.getElementsByTagName("conteudo_xml")[0].firstChild.nodeValue;
		var debug = item.getElementsByTagName("debug")[0].firstChild.nodeValue;

		if(status_xml==1){
			Tip(ico_alerta + 'e-mail inv&aacute;lido',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha.value="";
			f.senha2.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==2){
			Tip(ico_alerta + 'Preencha a nova senha',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha.value="";
			f.senha2.value="";
			window.setTimeout("f.senha.focus();",10);
		}
		else if(status_xml==3){
			Tip(ico_alerta + 'A nova senha deve ter pelo menos 6 caracteres',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha2.value="";
			window.setTimeout("f.senha.focus();",10);
		}
		else if(status_xml==4){
			Tip(ico_alerta + 'As senhas n&atilde;o confirmam<br /><br />Tente novamente',BALLOON,true,ABOVE,true,FIX,['senha', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha.value="";
			f.senha2.value="";
			window.setTimeout("f.senha.focus();",10);
		}
		else if(status_xml==5){
			Tip(ico_alerta + 'e-mail diferente do cadastro',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			f.senha.value="";
			f.senha2.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==6){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			msgajuda = eval(msg_xml);
			caixaimgcodigo_id.style.display = "";
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			tsenha_id.innerHTML = titulo_xml;
			isenha_id.innerHTML = input_xml;
			if(tsenha2_id){
				tsenha2_id.style.display = "none";
			}
			if(isenha2_id){
				isenha2_id.style.display = "none";
			}
			tipologin_id.value = tipo_xml;
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==7){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			msgajuda = eval(msg_xml);
			caixaimgcodigo_id.style.display = "";
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			tsenha_id.innerHTML = titulo_xml;
			isenha_id.innerHTML = input_xml;
			if(tsenha2_id){
				tsenha2_id.style.display = "none";
			}
			if(isenha2_id){
				isenha2_id.style.display = "none";
			}
			tipologin_id.value = tipo_xml;
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==8){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			window.setTimeout("f.senha2.focus();",10);
		}
		else if(status_xml==9){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			msgajuda = eval(msg_xml);
			caixalogin_id.innerHTML = conteudo_xml;
			tipologin_id.value = tipo_xml;
			window.setTimeout("f.senha.focus();",10);
		}
		else{
			Tip(ico_erro + 'Erro parametro n&atilde;o definido...',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
function processXMLvAtivar(obj){
	var dataArray = obj.getElementsByTagName("statuslogin");

	if(dataArray.length == 1){
		var item = dataArray[0];
		var status_xml = item.getElementsByTagName("status_xml")[0].firstChild.nodeValue;
		var msg_xml = item.getElementsByTagName("msg_xml")[0].firstChild.nodeValue;
		var imgcodigo_xml = item.getElementsByTagName("imgcodigo_xml")[0].firstChild.nodeValue;
		var tipo_xml = item.getElementsByTagName("tipo_xml")[0].firstChild.nodeValue;
		var conteudo_xml = item.getElementsByTagName("conteudo_xml")[0].firstChild.nodeValue;
		var debug = item.getElementsByTagName("debug")[0].firstChild.nodeValue;

		if(status_xml==1){
			Tip(ico_alerta + 'e-mail inv&aacute;lido',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==2){
			Tip(ico_alerta + 'c&oacute;digo inv&aacute;lido',BALLOON,true,ABOVE,false,FIX,['codigo', 0, -8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==3){
			Tip(ico_alerta + 'e-mail diferente do cadastro',BALLOON,true,ABOVE,true,FIX,['email', 0, 8],PADDING,8,CLICKCLOSE,true,WIDTH,-158);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==4){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			tipologin_id.value = tipo_xml;
			msgajuda = eval(msg_xml);
			f.codigo.value="";
			window.setTimeout("f.email.focus();",10);
		}
		else if(status_xml==5){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			msgajuda = eval(msg_xml);
			caixalogin_id.innerHTML = conteudo_xml;
			tipologin_id.value = tipo_xml;
			window.setTimeout("f.senha.focus();",10);
		}
		else if(status_xml==6){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			tipologin_id.value = tipo_xml;
			msgajuda = eval(msg_xml);
			f.codigo.value="";
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==7){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			caixaimgcodigo_id.innerHTML = imgcodigo_xml;
			tipologin_id.value = tipo_xml;
			f.codigo.value="";
			window.setTimeout("f.codigo.focus();",10);
		}
		else if(status_xml==8){
			Tip(eval(msg_xml),ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
			msgajuda = eval(msg_xml);
			caixalogin_id.innerHTML = conteudo_xml;
			tipologin_id.value = tipo_xml;
			window.setTimeout("f.senha.focus();",10);
		}
		else{
			Tip(ico_erro + 'Erro parametro n&atilde;o definido...',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
function chkLogin(e){
	var keycode;
	window.setTimeout("UnTip()",10);
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	if (keycode == 13){
		window.setTimeout("iniciarLogin()",10);
		return false;
	}
	else{
		return true;
	}
}
function esqueciSenha(){
	f = document.forms[0];
	aviso = false;
	tipologin_id = document.getElementById('tipologin');
	caixaimgcodigo_id = document.getElementById("caixaimgcodigo");
	tsenha_id = document.getElementById("tsenha");
	isenha_id = document.getElementById("isenha");
	ichkbox_id = document.getElementById("ichkbox");
	tlogado_id = document.getElementById("tlogado");
	botaologin_id = document.getElementById("botaologin");
	linklogin1_id = document.getElementById("linklogin1");
	//linklogin2_id = document.getElementById("linklogin2");

	var http=getXMLHTTPRequest();
	if(http){
		var params = '';
		http.open("POST", "includes/esqueci_senha.php?"+Math.random(), true);
		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){
				if(http.status == 200){
					processXMLesqueciSenha(http.responseXML);
				}
				else{
					Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[02]<br />erro ao tentar acessar os dados no servidor',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
				}
			}
		};
		http.send(params);
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[01]<br />erro XMLHttpRequest',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
	return false;
}
function processXMLesqueciSenha(obj){
	var dataArray = obj.getElementsByTagName("login");
	aviso = false;

	if(dataArray.length == 1) {
		var item = dataArray[0];
		var alerta_xml = item.getElementsByTagName("alerta_xml")[0].firstChild.nodeValue;
		var titulo_xml = item.getElementsByTagName("titulo_xml")[0].firstChild.nodeValue;
		var input_xml = item.getElementsByTagName("input_xml")[0].firstChild.nodeValue;
		var imgcodigo_xml = item.getElementsByTagName("imgcodigo_xml")[0].firstChild.nodeValue;
		var botao_xml = item.getElementsByTagName("botao_xml")[0].firstChild.nodeValue;
		var link_xml = item.getElementsByTagName("link_xml")[0].firstChild.nodeValue;

		msgajuda = ico_alerta + alerta_xml;
		Tip(ico_alerta + alerta_xml,ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);

		caixaimgcodigo_id.style.display = "";
		caixaimgcodigo_id.innerHTML = imgcodigo_xml;
		tsenha_id.innerHTML = titulo_xml;
		isenha_id.innerHTML = input_xml;

		ichkbox_id.innerHTML = "&nbsp;";
		tlogado_id.innerHTML = "&nbsp;";
		botaologin_id.innerHTML = botao_xml;
		linklogin1_id.innerHTML = link_xml;
		//linklogin2_id.style.display = "none";
		tipologin_id.value = 1;
		window.setTimeout("f.email.focus();",10);
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
function voltar(msg){
	f = document.forms[0];

	tsenha2_id = false;
	isenha2_id = false;
	tipologin_id = document.getElementById('tipologin');
	caixaimgcodigo_id = document.getElementById("caixaimgcodigo");
	tsenha_id = document.getElementById("tsenha");
	isenha_id = document.getElementById("isenha");
	if(document.getElementById("tsenha2")){
		tsenha2_id = document.getElementById("tsenha2");
	}
	if(document.getElementById("isenha2")){
		isenha2_id = document.getElementById("isenha2");
	}
	ichkbox_id = document.getElementById("ichkbox");
	tlogado_id = document.getElementById("tlogado");
	botaologin_id = document.getElementById("botaologin");
	linklogin1_id = document.getElementById("linklogin1");
	//linklogin2_id = document.getElementById("linklogin2");

	var http=getXMLHTTPRequest();
	if(http){
		var params = '';
		http.open("POST", "includes/voltar.php?"+Math.random(), true);
		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){
				if(http.status == 200){
					processXMLvoltar(http.responseXML,msg);
				}
				else{
					Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[02]<br />erro ao tentar acessar os dados no servidor',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
				}
			}
		};
		http.send(params);
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[01]<br />erro XMLHttpRequest',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
	return false;
}
function processXMLvoltar(obj,msg){
	var dataArray = obj.getElementsByTagName("login");

	if(dataArray.length == 1) {
		var item = dataArray[0];
		var msg_xml = item.getElementsByTagName("msg_xml")[0].firstChild.nodeValue;
		var titulo_xml = item.getElementsByTagName("titulo_xml")[0].firstChild.nodeValue;
		var input_xml = item.getElementsByTagName("input_xml")[0].firstChild.nodeValue;
		var chkbox_xml = item.getElementsByTagName("chkbox_xml")[0].firstChild.nodeValue;
		var logado_xml = item.getElementsByTagName("logado_xml")[0].firstChild.nodeValue;
		var botao_xml = item.getElementsByTagName("botao_xml")[0].firstChild.nodeValue;
		var link_xml = item.getElementsByTagName("link_xml")[0].firstChild.nodeValue;

		caixaimgcodigo_id.innerHTML = '&nbsp;';
		caixaimgcodigo_id.style.display = "none";
		tsenha_id.innerHTML = titulo_xml;
		isenha_id.innerHTML = input_xml;
		if(tsenha2_id){
			tsenha2_id.style.display = "none";
		}
		if(isenha2_id){
			isenha2_id.style.display = "none";
		}
		ichkbox_id.innerHTML = chkbox_xml;
		tlogado_id.innerHTML = logado_xml;
		botaologin_id.innerHTML = botao_xml;
		linklogin1_id.innerHTML = link_xml;
		//linklogin2_id.style.display = "";
		tipologin_id.value = 0;

		msgajuda = ico_alerta + msg_xml;

		if(msg){
			Tip(ico_alerta + msg,ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
		f.email.value = "";
		f.senha.value = "";
		window.setTimeout("f.email.focus();",10);
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
function alterarSenha(){
	caixalogado_id = document.getElementById('caixalogado');
	caixalogin_id = document.getElementById('caixalogin');

	return false;
}
function sairLogin(){
	f = document.forms[0];
	tipologin_id = document.getElementById('tipologin');
	caixalogado_id = document.getElementById('caixalogado');
	caixalogin_id = document.getElementById('caixalogin');
	var http=getXMLHTTPRequest();
	if(http){
		var params = "";
		Tip(ico_carregando + 'saindo...',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		http.open("POST", "includes/sair.php?"+Math.random(), true);
		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){
				if(http.status == 200){
					processXMLsairLogin(http.responseXML);
				}
				else{
					Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[02]<br />erro ao tentar acessar os dados no servidor',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
				}
			}
		};
		http.send(params);
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[01]<br />erro XMLHttpRequest',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
	return false;
}
function processXMLsairLogin(obj){
	var dataArray = obj.getElementsByTagName("statuslogin");

	if(dataArray.length == 1) {
		var item = dataArray[0];
		var status_xml = item.getElementsByTagName("status_xml")[0].firstChild.nodeValue;
		var diretorio_xml = item.getElementsByTagName("diretorio_xml")[0].firstChild.nodeValue;
		var conteudo_xml = item.getElementsByTagName("conteudo_xml")[0].firstChild.nodeValue;
		var msg_xml = item.getElementsByTagName("msg_xml")[0].firstChild.nodeValue;

		if(status_xml==0){
			document.location.href = "index.php";
		}
		else if(status_xml==1){
			tipologin_id.value = 0;
			caixalogado_id.innerHTML = "&nbsp;";
			caixalogado_id.style.display = "none";
			caixalogin_id.style.display = "";
			caixalogin_id.innerHTML = conteudo_xml;
			msgajuda = ico_alerta + msg_xml;
			UnTip();
			window.setTimeout("f.email.focus();",10);
		}
		else{
			Tip(ico_erro + 'Erro parametro n&atilde;o definido...',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
		}
	}
	else{
		Tip(ico_erro + 'Aten&ccedil;&atilde;o! Erro cod[03]<br />erro xml',ABOVE,true,FIX,['imgrestrito', -32, -8],PADDING,8,CLICKCLOSE,true,WIDTH,208);
	}
}
