function index(theForm)
{
    if (theForm.usuario.value == '' || theForm.senha.value == '')
    {
        alert('Acesso restrito!');
        theForm.usuario.value = '';
        theForm.senha.value = '';
        theForm.usuario.focus();
        return false;
    }
    if (theForm.usuario.value.indexOf(' ') != -1 || theForm.senha.value.indexOf(' ') != -1 || theForm.usuario.value.indexOf('\"') != -1 || theForm.senha.value.indexOf('\"') != -1 || theForm.usuario.value.indexOf('\'') != -1 || theForm.senha.value.indexOf('\'') != -1)
    {
        alert('Acesso restrito!');
        theForm.usuario.value = '';
        theForm.senha.value = '';
        theForm.usuario.focus();
        return false;
    }
    return true;
}
function minusculas(theElement)
{
	theElement.value = theElement.value.toLowerCase();
}
function mascaranumero(keypress)
{
	if (keypress > 47 && keypress < 58)
		return true;
	return false;
}
function mascaravalor(fld, milSep, decSep, e)
{
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
	len = fld.value.length;
	if (len < 14)
	{
		for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
		aux = '';
		for(; i < len; i++)
		if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
		aux += key;
		len = aux.length;
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		if (len > 2)
		{
			aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--)
			{
				if (j == 3)
				{
					aux2 += milSep;
					j = 0;
				}
				aux2 += aux.charAt(i);
				j++;
			}
			fld.value = '';
			len2 = aux2.length;
			for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
			fld.value += decSep + aux.substr(len - 2, len);
		}
		return false;
	}
	return false;
}
function mascaracep(keypress,theElement)
{
	campo = eval(theElement);
	separador1 = '.';
	separador2 = '-';
	conjunto1 = 2;
	conjunto2 = 6;
	if (keypress > 47 && keypress < 58)
	{
		if (campo.value.length == conjunto1)
			campo.value = campo.value + separador1;
		if (campo.value.length == conjunto2)
			campo.value = campo.value + separador2;
		return true;
	}
	else
		return false;
}
function mascaratelefone(keypress,theElement)
{
	campo = eval(theElement);
	separador1 = '(';
	separador2 = ')';
	separador3 = '-';
	conjunto1 = 0;
	conjunto2 = 3;
	conjunto3 = 8;
	if (keypress > 47 && keypress < 58)
	{
		if (campo.value.charAt(0) != '(')
			campo.value = '(' + campo.value
		if (campo.value.length == conjunto1)
			campo.value = campo.value + separador1;
		if (campo.value.length == conjunto2)
			campo.value = campo.value + separador2;
		if (campo.value.length == conjunto3)
			campo.value = campo.value + separador3;
		return true;
	}
	else
		return false;
}
function mascaradata(keypress,theElement)
{
	campo = eval(theElement);
	separador = '/';
	conjunto1 = 2;
	conjunto2 = 5;
	if (keypress > 47 && keypress < 58)
	{
		if (campo.value.length == conjunto1)
			campo.value = campo.value + separador;
		if (campo.value.length == conjunto2)
			campo.value = campo.value + separador;
		return true;
	}
	else
		return false;
}
function marcadesmarcatodos(theElement)
{
	var theForm = theElement.form;
	for (i = 0; i < theForm.length; i++)
	{
		if (theForm[i].type == 'checkbox' && !theForm[i].disabled & theForm[i].name != 'todos')
			theForm[i].checked = theElement.checked;
	}
}
function confirmaexclusao(theTextConfirm,theTextError,theForm)
{
    var encontrou = false;
	for (i = 0; i < theForm.length; i++)
	{
		if (theForm[i].type == 'checkbox' && !theForm[i].disabled & theForm[i].name != 'todos' && theForm[i].checked)
			encontrou = true;
	}
	if (encontrou)
	{
		if (confirm(theTextConfirm))
		    theForm.submit();
	}
	else
		alert(theTextError);
}
function confirmaexclusao1(theTextConfirm,theTextError,theForm,theFormAction)
{
    var encontrou = false;
	for (i = 0; i < theForm.length; i++)
	{
		if (theForm[i].type == 'checkbox' && !theForm[i].disabled & theForm[i].name != 'todos' && theForm[i].checked)
			encontrou = true;
	}
	if (encontrou)
	{
		if (confirm(theTextConfirm))
		{
			theForm.action = theFormAction;
		    theForm.submit();
		}
	}
	else
		alert(theTextError);
}
function cepajax(elemCEP,elemLogradouro,elemBairro,elemCidade,elemEstado)
{
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				return false;
			}
		}
	}
	var cep = elemCEP.value;
	cep = cep.replace('.','');
	cep = cep.replace('-','');
	xmlHttp.open("GET","ajaxcep.asp?cep="+cep,true);
	xmlHttp.onreadystatechange = function()
	{
		if (xmlHttp.readyState == 4)
		{
			var r = xmlHttp.responseText;
			var logradouro = r.substring(0,(i = r.indexOf('¦')));
			r = r.substring(++i);
			var bairro = r.substring(0,(i = r.indexOf('¦')));
			r = r.substring(++i);
			var cidade = r.substring(0,(i = r.indexOf('¦')));
			r = r.substring(++i);
			var estado = r.substring(0,(i = r.indexOf('¦')));
			elemLogradouro.value = logradouro;
			elemBairro.value = bairro;
			elemCidade.value = cidade;
			var i = elemEstado.options.length;
			while (i--)
			{
				if (elemEstado.options[i].getAttribute("value") == estado)
				{
					break;
				}
			}
			elemEstado.selectedIndex = i;
		}
	}
	xmlHttp.send(null);
}
function diavencimentoajax(elemCliente,elemDataVencimento)
{
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				return false;
			}
		}
	}
	var cliente_id = elemCliente.options[elemCliente.selectedIndex].value;
	xmlHttp.open("GET","ajaxdiavencimento.asp?cliente_id="+cliente_id,true);
	xmlHttp.onreadystatechange = function()
	{
		if (xmlHttp.readyState == 4)
		{
			var diavencimento = xmlHttp.responseText;
			elemDataVencimento.value = diavencimento;
		}
	}
	xmlHttp.send(null);
}
function verificaemail(theElement)
{
	if (theElement.value == '')
	{
		alert('Digite o e-mail!');
		theElement.focus();
		return false;
	}
	else
	{
		prim = theElement.value.indexOf('@');
		if (prim < 2)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('@',prim + 1) != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('.') < 1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf(' ') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf(';') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('.@') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('@.') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('.com.br.') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('/') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('[') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf(']') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('(') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf(')') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('"') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('\'') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
		if (theElement.value.indexOf('..') != -1)
		{
			alert('O e-mail informado não parece estar correto!');
			theElement.focus();
			return false;
		}
	}
	return true;
}
function verificadata(theElement)
{
	var dia = parseInt(theElement.value.substring(0,2),10);
	var mes = parseInt(theElement.value.substring(3,5),10);
	var ano = parseInt(theElement.value.substring(6,10),10);
	data = new Date();
	if (dia <= 31 && mes <= 12 && ano >= 1900)
	{
		if (theElement.value.substring(0,1) == '0' && theElement.value.substring(1,2) != '0' || theElement.value.substring(0,1) != '0')
		{
			if (theElement.value.substring(2,3) == '/')
			{
				if (theElement.value.substring(3,4) == '0' && theElement.value.substring(4,5) != '0' || theElement.value.substring(3,4) != '0')
				{
					if (theElement.value.substring(5,6) == '/')
					{
						if (theElement.value.substring(6,7) == '0' || theElement.value.substring(6,7) == '' && theElement.value.substring(7,8) != '0')
						{
							alert('Verifique a data!');
							theElement.focus();
							return false;
						}
						if (mes == 2)
						{
							if ((dia > 0) && (dia <= 29))
							{
								if (dia == 29)
								{
									if ((ano % 4) != 0)
									{
										alert('Verifique a data!');
										theElement.focus();
										return false;
									}
								}
							}
							else
							{
								alert('Verifique a data!');
								theElement.focus();
								return false; 
							}
						}
						if ((mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))
						{
							if (!((dia > 0 ) && (dia <= 30)))
							{
								alert('Verifique a data!');
								theElement.focus();
								return false;
							}
						}
						if ((mes == 1) || (mes == 3) || (mes == 5) || (mes ==7) || (mes == 8) || (mes == 10) || (mes == 12))
						{
							if (!((dia > 0) && (dia <= 31)))
							{
								alert('Verifique a data!');
								theElement.focus();
								return false;
							}
						}
					}
					else
					{
						alert('Verifique a data!');
						theElement.focus();
						return false;
					}
				}
				else
				{
					alert('Verifique a data!');
					theElement.focus();
					return false;
				}
			}
			else
			{
				alert('Verifique a data!');
				theElement.focus();
				return false;
			}
		}
		else
		{
			alert('Verifique a data!');
			theElement.focus();
			return false;
		}
	}
	else
	{
		alert('Verifique a data!');
		theElement.focus();
		return false;
	}
	return true;
}
function verificadata1(theElement)
{
	var dia = parseInt(theElement.value.substring(0,2),10);
	var mes = parseInt(theElement.value.substring(3,5),10);
	var ano = parseInt(theElement.value.substring(6,10),10);
	data = new Date();
	if (dia <= 28 && mes <= 12 && ano >= 1900)
	{
		if (theElement.value.substring(0,1) == '0' && theElement.value.substring(1,2) != '0' || theElement.value.substring(0,1) != '0')
		{
			if (theElement.value.substring(2,3) == '/')
			{
				if (theElement.value.substring(3,4) == '0' && theElement.value.substring(4,5) != '0' || theElement.value.substring(3,4) != '0')
				{
					if (theElement.value.substring(5,6) == '/')
					{
						if (theElement.value.substring(6,7) == '0' || theElement.value.substring(6,7) == '' && theElement.value.substring(7,8) != '0')
						{
							alert('Verifique a data!');
							theElement.focus();
							return false;
						}
						if (mes == 2)
						{
							if ((dia > 0) && (dia <= 29))
							{
								if (dia == 29)
								{
									if ((ano % 4) != 0)
									{
										alert('Verifique a data!');
										theElement.focus();
										return false;
									}
								}
							}
							else
							{
								alert('Verifique a data!');
								theElement.focus();
								return false; 
							}
						}
						if ((mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))
						{
							if (!((dia > 0 ) && (dia <= 30)))
							{
								alert('Verifique a data!');
								theElement.focus();
								return false;
							}
						}
						if ((mes == 1) || (mes == 3) || (mes == 5) || (mes ==7) || (mes == 8) || (mes == 10) || (mes == 12))
						{
							if (!((dia > 0) && (dia <= 31)))
							{
								alert('Verifique a data!');
								theElement.focus();
								return false;
							}
						}
					}
					else
					{
						alert('Verifique a data!');
						theElement.focus();
						return false;
					}
				}
				else
				{
					alert('Verifique a data!');
					theElement.focus();
					return false;
				}
			}
			else
			{
				alert('Verifique a data!');
				theElement.focus();
				return false;
			}
		}
		else
		{
			alert('Verifique a data!');
			theElement.focus();
			return false;
		}
	}
	else
	{
		alert('Verifique a data!');
		theElement.focus();
		return false;
	}
	return true;
}
function filtradatas(theForm)
{
	if (theForm.datade.value != '')
		if (!verificadata(theForm.datade))
			return false;
	if (theForm.dataate.value != '')
		if (!verificadata(theForm.dataate))
			return false;
	return true;
}
function despesasorigens(theForm)
{
	if (theForm.despesaorigem.value == '')
    {
        alert('Digite a origem da despesa!');
        theForm.despesaorigem.focus();
        return false;
    }
	return true;
}
function receitasorigens(theForm)
{
	if (theForm.receitaorigem.value == '')
    {
        alert('Digite a origem da receita!');
        theForm.receitaorigem.focus();
        return false;
    }
	return true;
}
function clientes(theForm)
{
	if (theForm.nomerazao.value == '')
	{
		alert('Digite o nome/razão social!');
		theForm.nomerazao.focus();
		return false;
	}
	if (theForm.fantasia.value == '')
	{
		alert('Digite o nome fantasia!');
		theForm.fantasia.focus();
		return false;
	}
	if (theForm.cpfcnpj.value == '')
	{
		alert('Digite o CPF/CNPJ!');
		theForm.cpfcnpj.focus();
		return false;
	}
	if (theForm.cpfcnpj.value.length != 11 && theForm.cpfcnpj.value.length != 14)
	{
		alert('Verifique o CPF/CNPJ!');
		theForm.cpfcnpj.focus();
		return false;
	}
	if (theForm.cep.value == '')
	{
		alert('Digite o CEP!');
		theForm.cep.focus();
		return false;
	}
	if (theForm.cep.value.length != 10)
	{
		alert('Verifique o CEP!');
		theForm.cep.focus();
		return false;
	}
	if (theForm.logradouro.value == '')
	{
		alert('Digite o logradouro!');
		theForm.logradouro.focus();
		return false;
	}
	if (theForm.numero.value == '')
	{
		alert('Digite o número!');
		theForm.numero.focus();
		return false;
	}
	if (theForm.bairro.value == '')
	{
		alert('Digite o bairro!');
		theForm.bairro.focus();
		return false;
	}
	if (theForm.cidade.value == '')
	{
		alert('Digite o cidade!');
		theForm.cidade.focus();
		return false;
	}
	if (theForm.estado.selectedIndex == -1)
	{
		alert("Selecione o estado!");
		theForm.estado.focus();
		return false;
	}
	if (theForm.telefone.value == '')
	{
		alert('Digite o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.telefone.value.length != 13)
	{
		alert('Verifique o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.celular.value != '')
	{
		if (theForm.celular.value.length != 13)
		{
			alert('Verifique o telefone!');
			theForm.celular.focus();
			return false;
		}
	}
	if (theForm.fax.value != '')
	{
		if (theForm.fax.value.length != 13)
		{
			alert('Verifique o fax!');
			theForm.fax.focus();
			return false;
		}
	}
	if (theForm.email1.value == '')
	{
		alert('Digite o e-mail principal!');
		theForm.email1.focus();
		return false;
	}
	else
		if (!verificaemail(theForm.email1))
		    return false;
	if (theForm.email2.value == '')
	{
		alert('Digite o e-mail alternativo!');
		theForm.email2.focus();
		return false;
	}
	else
		if (!verificaemail(theForm.email2))
			return false;
	if (theForm.diavencimento.value == '')
	{
		alert('Digite o dia do vencimento!');
		theForm.diavencimento.focus();
		return false;
	}
	if (parseInt(theForm.diavencimento.value) < 1 || parseInt(theForm.diavencimento.value) > 28)
	{
		alert('Verifique o dia do vencimento!');
		theForm.diavencimento.focus();
		return false;
	}
    return true;
}
function empresas(theForm)
{
	if (theForm.nomerazao.value == '')
	{
		alert('Digite o nome/razão social!');
		theForm.nomerazao.focus();
		return false;
	}
	if (theForm.fantasia.value == '')
	{
		alert('Digite o nome fantasia!');
		theForm.fantasia.focus();
		return false;
	}
	if (theForm.cpfcnpj.value == '')
	{
		alert('Digite o CPF/CNPJ!');
		theForm.cpfcnpj.focus();
		return false;
	}
	if (theForm.cpfcnpj.value.length != 11 && theForm.cpfcnpj.value.length != 14)
	{
		alert('Verifique o CPF/CNPJ!');
		theForm.cpfcnpj.focus();
		return false;
	}
	if (theForm.cep.value == '')
	{
		alert('Digite o CEP!');
		theForm.cep.focus();
		return false;
	}
	if (theForm.cep.value.length != 10)
	{
		alert('Verifique o CEP!');
		theForm.cep.focus();
		return false;
	}
	if (theForm.logradouro.value == '')
	{
		alert('Digite o logradouro!');
		theForm.logradouro.focus();
		return false;
	}
	if (theForm.numero.value == '')
	{
		alert('Digite o número!');
		theForm.numero.focus();
		return false;
	}
	if (theForm.bairro.value == '')
	{
		alert('Digite o bairro!');
		theForm.bairro.focus();
		return false;
	}
	if (theForm.cidade.value == '')
	{
		alert('Digite o cidade!');
		theForm.cidade.focus();
		return false;
	}
	if (theForm.estado.selectedIndex == -1)
	{
		alert("Selecione o estado!");
		theForm.estado.focus();
		return false;
	}
	if (theForm.telefone.value == '')
	{
		alert('Digite o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.telefone.value.length != 13)
	{
		alert('Verifique o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.celular.value != '')
	{
		if (theForm.celular.value.length != 13)
		{
			alert('Verifique o telefone!');
			theForm.celular.focus();
			return false;
		}
	}
	if (theForm.fax.value != '')
	{
		if (theForm.fax.value.length != 13)
		{
			alert('Verifique o fax!');
			theForm.fax.focus();
			return false;
		}
	}
	if (theForm.email1.value == '')
	{
		alert('Digite o e-mail principal!');
		theForm.email1.focus();
		return false;
	}
	else
		if (!verificaemail(theForm.email1))
		    return false;
	if (theForm.email2.value == '')
	{
		alert('Digite o e-mail alternativo!');
		theForm.email2.focus();
		return false;
	}
	else
		if (!verificaemail(theForm.email2))
			return false;
    return true;
}
function fornecedores(theForm)
{
	if (theForm.nomerazao.value == '')
	{
		alert('Digite o nome/razão social!');
		theForm.nomerazao.focus();
		return false;
	}
	if (theForm.fantasia.value == '')
	{
		alert('Digite o nome fantasia!');
		theForm.fantasia.focus();
		return false;
	}
	if (theForm.cpfcnpj.value == '')
	{
		alert('Digite o CPF/CNPJ!');
		theForm.cpfcnpj.focus();
		return false;
	}
	if (theForm.cpfcnpj.value.length != 11 && theForm.cpfcnpj.value.length != 14)
	{
		alert('Verifique o CPF/CNPJ!');
		theForm.cpfcnpj.focus();
		return false;
	}
	if (theForm.cep.value == '')
	{
		alert('Digite o CEP!');
		theForm.cep.focus();
		return false;
	}
	if (theForm.cep.value.length != 10)
	{
		alert('Verifique o CEP!');
		theForm.cep.focus();
		return false;
	}
	if (theForm.logradouro.value == '')
	{
		alert('Digite o logradouro!');
		theForm.logradouro.focus();
		return false;
	}
	if (theForm.numero.value == '')
	{
		alert('Digite o número!');
		theForm.numero.focus();
		return false;
	}
	if (theForm.bairro.value == '')
	{
		alert('Digite o bairro!');
		theForm.bairro.focus();
		return false;
	}
	if (theForm.cidade.value == '')
	{
		alert('Digite o cidade!');
		theForm.cidade.focus();
		return false;
	}
	if (theForm.estado.selectedIndex == -1)
	{
		alert("Selecione o estado!");
		theForm.estado.focus();
		return false;
	}
	if (theForm.telefone.value == '')
	{
		alert('Digite o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.telefone.value.length != 13)
	{
		alert('Verifique o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.celular.value != '')
	{
		if (theForm.celular.value.length != 13)
		{
			alert('Verifique o telefone!');
			theForm.celular.focus();
			return false;
		}
	}
	if (theForm.fax.value != '')
	{
		if (theForm.fax.value.length != 13)
		{
			alert('Verifique o fax!');
			theForm.fax.focus();
			return false;
		}
	}
	if (theForm.email1.value != '')
		if (!verificaemail(theForm.email1))
		    return false;
	if (theForm.email2.value != '')
		if (!verificaemail(theForm.email2))
			return false;
    return true;
}
function dados(theForm)
{
	if (theForm.telefone.value == '')
	{
		alert('Digite o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (theForm.telefone.value.length != 13)
	{
		alert('Verifique o telefone!');
		theForm.telefone.focus();
		return false;
	}
	if (!verificaemail(theForm.email))
	    return false;
	if (theForm.usuario.value == '')
	{
		alert('Digite o login!');
		theForm.usuario.focus();
		return false;
	}
	if (theForm.usuario.value.length < 5)
	{
		alert('Escolha um login com pelo menos 5 caracteres!');
		theForm.usuario.value = '';
		theForm.usuario.focus();
		return false;
	}
	if (theForm.usuario.value.indexOf(' ') != -1)
	{
		alert('O login não permite a inclusão de espaços!');
		theForm.usuario.value = '';
		theForm.usuario.focus();
		return false;
	}
	if (theForm.usuario.value.indexOf('\"') != -1)
	{
		alert('O login não permite a inclusão de aspas!');
		theForm.usuario.value = '';
		theForm.usuario.focus();
		return false;
	}
	if (theForm.usuario.value.indexOf('\'') != -1)
	{
		alert('O login não permite a inclusão de aspas!');
		theForm.usuario.value = '';
		theForm.usuario.focus();
		return false;
	}
	if (theForm.senha1.value == '')
	{
		alert('Digite a senha!');
		theForm.senha1.focus();
		return false;
	}
	if (theForm.senha1.value.length < 5)
	{
		alert('Escolha uma senha com pelo menos 5 caracteres!');
		theForm.senha1.value = '';
		theForm.senha1.focus();
		return false;
	}
	if (theForm.senha1.value.indexOf(' ') != -1)
	{
		alert('A senha não permite a inclusão de espaços!');
		theForm.senha1.value = '';
		theForm.senha1.focus();
		return false;
	}
	if (theForm.senha1.value.indexOf('\"') != -1)
	{
		alert('A senha não permite a inclusão de aspas!');
		theForm.senha1.value = '';
		theForm.senha1.focus();
		return false;
	}
	if (theForm.senha1.value.indexOf('\'') != -1)
	{
		alert('A senha não permite a inclusão de aspas!');
		theForm.senha1.value = '';
		theForm.senha1.focus();
		return false;
	}
	if (theForm.senha2.value == '')
	{
		alert('Confirme a senha!');
		theForm.senha2.focus();
		return false;
	}
	if (theForm.senha1.value != theForm.senha2.value)
	{
		alert('Verifique a senha!');
		theForm.senha1.value = '';
		theForm.senha2.value = '';
		theForm.senha1.focus();
		return false;
	}
	return true;
}
function usuarios(theForm)
{
    if (theForm.nome.value == '')
	{
		alert('Digite o nome!');
		theForm.nome.focus();
		return false;
	}
	if (!dados(theForm))
		return false;
    return true;
}
function usuariosper(theForm)
{
	if (theForm.perfil_id.selectedIndex == -1)
	{
		alert("Selecione o perfil!");
		theForm.perfil_id.focus();
		return false;
	}
	return true;
}
function receitas(theForm,acao)
{
	if (theForm.conta_id.selectedIndex == -1)
	{
		alert("Selecione a conta!");
		theForm.conta_id.focus();
		return false;
	}
	if (theForm.receitaorigem_id.selectedIndex == -1)
	{
		alert("Selecione a origem da receita!");
		theForm.receitaorigem_id.focus();
		return false;
	}
    if (acao == 'ins')
	{
		if (theForm.parcelas.value == '' || theForm.parcelas.value == '0')
		{
			alert('Digite a quantidade de parcelas!');
			theForm.parcelas.focus();
			return false;
		}
	}
	if (theForm.datavencimento.value == '')
	{
		alert('Digite a data de vencimento!');
		theForm.datavencimento.focus();
		return false;
	}
	else
		if (theForm.parcelas.value == '1')
		{
			if (!verificadata(theForm.datavencimento))
				return false;
		}
		else
		{
			if (!verificadata1(theForm.datavencimento))
				return false;
		}
	if (theForm.valorvencimento.value == '')
	{
		alert('Digite o valor de vencimento!');
		theForm.valorvencimento.focus();
		return false;
	}
	if (acao == 'upd')
	{
		if (theForm.status.value != '0')
		{
			if (theForm.dataquitacao.value == '')
			{
				alert('Digite a data de quitação!');
				theForm.dataquitacao.focus();
				return false;
			}
			else
				if (!verificadata(theForm.dataquitacao))
					return false;
			if (theForm.valorquitacao.value == '')
			{
				alert('Digite o valor de quitação!');
				theForm.valorquitacao.focus();
				return false;
			}
		}
		if (theForm.nf.value != '')
		{
			if (theForm.datanf.value == '')
			{
				alert('Digite a data da nota fiscal!');
				theForm.datanf.focus();
				return false;
			}
			else
				if (!verificadata(theForm.datanf))
					return false;
			if (theForm.valornf.value == '')
			{
				alert('Digite o valor da nota fiscal!');
				theForm.valornf.focus();
				return false;
			}
		}
	}
	return true;
}
function receitasqui(theForm)
{
	if (theForm.dataquitacao.value == '')
	{
		alert('Digite a data de quitação!');
		theForm.dataquitacao.focus();
		return false;
	}
	else
		if (!verificadata(theForm.dataquitacao))
			return false;
	if (theForm.valorquitacao.value == '')
	{
		alert('Digite o valor de quitação!');
		theForm.valorquitacao.focus();
		return false;
	}
	if (theForm.nf.value != '')
	{
		if (theForm.datanf.value == '')
		{
			alert('Digite a data da nota fiscal!');
			theForm.datanf.focus();
			return false;
		}
		else
			if (!verificadata(theForm.datanf))
				return false;
		if (theForm.valornf.value == '')
		{
			alert('Digite o valor da nota fiscal!');
			theForm.valornf.focus();
			return false;
		}
	}
    return true;
}
function receitascob(theForm)
{
	if (theForm.conta_id.selectedIndex == -1)
	{
		alert("Selecione a conta!");
		theForm.conta_id.focus();
		return false;
	}
	if (theForm.datavencimento.value == '')
	{
		alert('Digite a data de vencimento!');
		theForm.datavencimento.focus();
		return false;
	}
	else
		if (!verificadata(theForm.datavencimento))
			return false;
	if (theForm.valorvencimento.value == '')
	{
		alert('Digite o valor de vencimento!');
		theForm.valorvencimento.focus();
		return false;
	}
	if (theForm.dataquitacao.value != '')
	{
		if (!verificadata(theForm.dataquitacao))
			return false;
		if (theForm.valorquitacao.value == '')
		{
			alert('Digite o valor de quitação!');
			theForm.valorquitacao.focus();
			return false;
		}
	}
	if (theForm.nf.value != '')
	{
		if (theForm.datanf.value == '')
		{
			alert('Digite a data da nota fiscal!');
			theForm.datanf.focus();
			return false;
		}
		else
			if (!verificadata(theForm.datanf))
				return false;
		if (theForm.valornf.value == '')
		{
			alert('Digite o valor da nota fiscal!');
			theForm.valornf.focus();
			return false;
		}
	}
	return true;
}
function despesas(theForm,acao)
{
	if (theForm.conta_id.selectedIndex == -1)
	{
		alert("Selecione a conta!");
		theForm.conta_id.focus();
		return false;
	}
	if (theForm.despesaorigem_id.selectedIndex == -1)
	{
		alert("Selecione a origem da despesa!");
		theForm.despesaorigem_id.focus();
		return false;
	}
    if (acao == 'ins')
	{
		if (theForm.parcelas.value == '' || theForm.parcelas.value == '0')
		{
			alert('Digite a quantidade de parcelas!');
			theForm.parcelas.focus();
			return false;
		}
	}
	if (theForm.datavencimento.value == '')
	{
		alert('Digite a data de vencimento!');
		theForm.datavencimento.focus();
		return false;
	}
	else
		if (!verificadata(theForm.datavencimento))
			return false;
	if (theForm.valorvencimento.value == '')
	{
		alert('Digite o valor de vencimento!');
		theForm.valorvencimento.focus();
		return false;
	}
	if (acao == 'upd')
	{
		if (theForm.status.value != '0')
		{
			if (theForm.dataquitacao.value == '')
			{
				alert('Digite a data de quitação!');
				theForm.dataquitacao.focus();
				return false;
			}
			else
				if (!verificadata(theForm.dataquitacao))
					return false;
			if (theForm.valorquitacao.value == '')
			{
				alert('Digite o valor de quitação!');
				theForm.valorquitacao.focus();
				return false;
			}
		}
		if (theForm.nf.value != '')
		{
			if (theForm.datanf.value == '')
			{
				alert('Digite a data da nota fiscal!');
				theForm.datanf.focus();
				return false;
			}
			else
				if (!verificadata(theForm.datanf))
					return false;
			if (theForm.valornf.value == '')
			{
				alert('Digite o valor da nota fiscal!');
				theForm.valornf.focus();
				return false;
			}
		}
	}
	return true;
}
function despesasqui(theForm)
{
	if (!receitasqui(theForm))
		return false;
    return true;
}
function contas(theForm)
{
	if (theForm.conta.value == '')
	{
		alert('Digite o nome da conta!');
		theForm.conta.focus();
		return false;
	}
	if (theForm.empresa_id.selectedIndex == -1)
	{
		alert("Selecione a empresa!");
		theForm.empresa_id.focus();
		return false;
	}
	if (theForm.banco.selectedIndex == -1)
	{
		alert("Selecione o banco!");
		theForm.banco.focus();
		return false;
	}
	if (theForm.agencia.value == '')
	{
		alert('Digite o código da agência!');
		theForm.agencia.focus();
		return false;
	}
	if (theForm.contacorrente.value == '')
	{
		alert('Digite o número da conta corrente!');
		theForm.contacorrente.focus();
		return false;
	}
	if (theForm.taxa.value == '')
	{
		alert('Digite a taxa de cobrança!');
		theForm.taxa.focus();
		return false;
	}
	return true;
}
function cobrancasupd(theForm)
{
	if (!receitascob(theForm))
		return false;
	return true;
}
function cobrancasqui(theForm)
{
	if (!receitasqui(theForm))
		return false;
	return true;
}
function relatorios(theForm)
{
	if (theForm.relatorio.selectedIndex == -1)
	{
		alert("Selecione o relatório!");
		theForm.relatorio.focus();
		return false;
	}
	return true;
}
function relatorio1(theForm)
{
	if (theForm.conta_id.selectedIndex == -1)
	{
		alert("Selecione a conta!");
		theForm.conta_id.focus();
		return false;
	}
	if (theForm.datade.value == '' || theForm.dataate.value == '')
	{
		alert("Digite o período!");
		theForm.datade.focus();
		return false;
	}
	if (!filtradatas(theForm))
		return false;
	return true;
}
function relatorio2(theForm)
{
	if (!relatorio1(theForm))
		return false;
	return true;
}
