function validaLogin(objform)
{	
	var usuario = objform.str_usuario;
	var senha = objform.str_senha;
	if ((usuario.value == "")||(usuario.value == "usuario"))
	{
		alert('Preencha os campos Usuário / Senha e clique no Sistema que deseja acessar.');
		usuario.focus();
		return false;
	}
    if ((senha.value == "")||(senha.value == "senha"))
	{
		alert('Preencha os campos Usuário / Senha e clique no Sistema que deseja acessar.');
		senha.focus();
		return false;
	}
	return true;
}
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			manda()
		} 
	}      
              
function manda(objform) 
{	
	var width = 788;
	var height = 550;
	var LeftPosition, TopPosition;
	var frmAction = objform.webseek.value;
	if (screen.width == 800){
		LeftPosition = 0;
		TopPosition = 0;
	}
	else{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height-60)/2 : 0;
	}
	var janela = window.open("","popup_webseek",'width='+width+',height='+height+',resizable=1,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,status=no,toolbars=no');
	
	objform.action = frmAction;

	objform.target="popup_webseek";
	objform.submit();
	objform.str_senha.value="";
	janela.focus();
}
function manda_apol(objform) 
{
	var usuario = objform.str_usuario.value;
	var senha = objform.str_senha.value;
	
	var width = 788;
	var height = 718;
	var LeftPosition, TopPosition;
	var frmAction = objform.apol.value;
	if (screen.width == 800){
		LeftPosition = 0;
		TopPosition = 0;
	}
	else{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height-60)/2 : 0;
	}

	var janela = window.open("","popup_apol",'width='+width+',height='+height+',resizable=0,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,status=no,toolbars=no');
	
	objform.txt_usuario.value = usuario;
	objform.txt_senha.value = senha;
	
	objform.action = frmAction;
	
	objform.target="popup_apol";
	objform.submit();
	objform.str_senha.value="";
	janela.focus();
}

function trimAll(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
return sString;
}
	
function ValidaBuscaCliente(objForm)
{
    var cliente = objForm.radical;
	cliente.value = trimAll(cliente.value);
	if ((cliente.value=="nome da empresa") || (cliente.value=="") || (cliente.value.length < 3))
	{
		alert('Escreva um radical para clientes com 3 caracteres no mínimo.');
		cliente.focus();
		return false;
	}
	
	return true;
}
function SubmitLoginSuporte(objFrm,acao)
{
	if(acao=='lu')
	{
		if ((objFrm.email.value == "")||(objFrm.email.value == "login"))
		{
			alert('Informe o seu login.');// e clique no Sistema que deseja acessar.');
			objFrm.email.focus();
			return false;
		}
	    if ((objFrm.senha.value == "")||(objFrm.senha.value == "senha")&&!ValidaEmail(objFrm.email.value))
		{
			alert('Informe a sua senha.');// e clique no Sistema que deseja acessar.');
			objFrm.senha.focus();
			return false;		
		}
	}
	else
	{
		if ((objFrm.email.value == "")||(objFrm.email.value == "login")) {
			alert('Informe o email para o qual será enviado login e senha.');
			objFrm.email.focus();
			return false;
		}
		if (!ValidaEmail(objFrm.email.value))
		{
			alert('Email inválido.\nPreencha o email no campo de login.');// e clique no Sistema que deseja acessar.');
			objFrm.email.focus();
			return false;		
		}
	}		

	objFrm.acao.value = acao;
	objFrm.submit();
}

function abre_apol(){
	var width = 788;
	var height = 550;
	var LeftPosition, TopPosition;
	

	
	if (screen.width == 800){
		LeftPosition = 0;
		TopPosition = 0;
	}
	else{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height-60)/2 : 0;
	}
	window.open("http://ld2.ldsoft.com.br/siteld/cadastro_teste.asp?novo=S&apol=S","popup_apol",'width='+width+',height='+height+',resizable=0,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,status=no,toolbars=no');
}

function abre_webseek() 
{	
	var width = 788;
	var height = 550;
	var LeftPosition, TopPosition;
	if (screen.width == 800){
		LeftPosition = 0;
		TopPosition = 0;
	}
	else{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height-60)/2 : 0;
	}
	window.open("http://ld2.ldsoft.com.br/siteld/cadastro_teste.asp?novo=S&webseek=S","popup_webseek",'width='+width+',height='+height+',resizable=0,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,status=no,toolbars=no');
}

function ValidaEmail(Email)
{
	var txt = Email;
	if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
	{
		return false
	}
	return true
}
