function openBox(n)
{
	for (var i=0;i<document.getElementsByTagName("textarea").length;i++)
	{
		if (document.getElementsByName(n)[0] != document.getElementsByTagName("textarea")[i] && document.getElementsByTagName("textarea")[i].style.display == 'block')
		{
			document.getElementsByTagName("textarea")[i].style.display='none';
		}
	}
	
	if(document.getElementsByName(n)[0].style.display == 'block')
	{
		document.getElementsByName(n)[0].style.display='none';
		document.frmorc.btnsubmitorc.style.display='none';
		document.frmorc.btnsubmitorc.disabled=0;
	}
	else
	{
		document.getElementsByName(n)[0].style.display='block';
		document.frmorc.btnsubmitorc.style.display='inline';
		document.getElementById("destino").value = document.getElementsByName(n)[0].name;
		document.frmorc.btnsubmitorc.disabled=0;
	}
}

function mostra_img(id,no_img,ancora)
{
if (document.getElementById("pagemark") != null && document.getElementById("pagemark").value == "index")
{
document.getElementById("zoom").style.top='0px';
}
	requisicao_ajax_lista('produto.asp',no_img,id,ancora);
	try 
		{
            	$("#zoom").fadeIn(400);
        }
		catch(e)
		{
			document.getElementById('zoom').style.display='block';       //show('slow');
		}
}




function requisicao_ajax_lista(pagina,index_img,id,nome) //página, ação e tabela, respectivamente no crud/ pagina, login e senha no login.
{	name = nome;
	tabela = id;
	page = pagina;
        try 
		{
            ajax = new ActiveXObject("Microsoft.XMLHTTP");
        }
		catch(e)
		{
            try {
                ajax = new ActiveXObject("Msxml2.XMLHTTP");
				} 
				catch(ex) 
				{
					try {
                    ajax = new XMLHttpRequest();
						}
					catch(exc)
					{
                    alert("Esse browser não suporta Ajax");
                    ajax = null;
					}
				}
        }
	//----------
	if (!ajax)
	{
		//Nao conseguiu instanciar o objeto xmlhttp para fazer as solicitacoes
		alert("AJAX error. Your browser must support XMLHttpRequest object or enable use of scripting.");
	}
	if(ajax != null)
	{	
		if(pagina == 'validacep.asp')
		{
			metodo=	'POST';
			args='cep=' + index_img;
			argsurl='';
		}
		else if(pagina=='testalogin.asp')
		{
			metodo = 'POST';
			args = 'login=' + index_img ;
			argsurl = '';
		}
		else if (pagina=='actcrud.asp')
		{	
			metodo = 'GET';
			args=null;
			argsurl ='?acao='+ index_img + '&item=' + id;
		}
		else if (pagina=='logincliente.asp')
		{
			metodo = 'POST';
			argsurl = '';
			args = 'index=' + index_img + '&id=' + id;
		}
		else if(pagina=='logoutcliente.asp')
		{	
			metodo = 'POST';
			argsurl='';
			args = 'mais_um_bug_do_ff=2';
		}
		else if (pagina=='edit.asp')
		{	
			metodo='POST';
			argsurl='';
			args= 'valores=' + index_img + '&nome_categoria=' + id;
		}
		else if(pagina=='validaemail.asp')
		{
			metodo='POST'
			argsurl='';
			args='ajax=' + id + '&e-mail=' + index_img;
		}
		else
		{
			metodo = 'GET';
			argsurl='?index='+ index_img + '&id=' + id + '&q=' + name;
			args = null;
		}
			ajax.open(metodo,pagina + argsurl,true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
            ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
            ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
            ajax.setRequestHeader("Pragma", "no-cache");
			ajax.onreadystatechange = status_ajax_lista;
			ajax.send(args);
			
	}
	else
	{
		window.alert('Erro desconhecido!');
	}
}

	function status_ajax_lista()
	{	
		if (ajax.readyState < 4)
		{	
			
			if (page == 'produto.asp' || page == 'validacep.asp')
			{
				document.getElementById("zoom").innerHTML = "<center><img src='img/ajax-loader.gif'></center>";
				
			}
			else if (page =='testalogin.asp')
			{
				document.getElementById("zoom").innerHTML = "<center>Verificando se o Se login está disponível, por favor aguarde.<br><img src='img/ajax-loader.gif'></center>";
			}
			else if(page=='actcrud.asp')
			{
				if (tabela== 'tabprodutos')
				{
					document.getElementById("delproduto").innerHTML= "<center><img src='img/ajax-loader.gif'></center>";
				}
				else if (tabela == 'tabcategoria')
				{
					document.getElementById("delcategoria").innerHTML= "<center><img src='img/ajax-loader.gif'></center>";
				}
				else if (tabela== 'moderador')
				{
					document.getElementById("delmoderador").innerHTML= "<center><img src='img/ajax-loader.gif'></center>";
				}
				else if(tabela =='tabvendedor')
				{
					document.getElementById("delvendedor").innerHTML= "<center><img src='img/ajax-loader.gif'></center>";
				}
			}
			else if (page=='filtro.asp')
			{
				document.getElementById("foto").innerHTML = "<center><img src='img/ajax-loader.gif'></center>";
			}
			else if (page=='logincliente.asp' || page=='logoutcliente.asp')
			{
				document.getElementById("cliente").innerHTML = "<img src='img/ajax-loader.gif'>";
			}
			else if(page=='edit.asp')
			{
				document.getElementById("edtcadastros").innerHTML = '<center><img src="img/ajax-loader.gif"></center>';
			}
			else if(page=='validaemail.asp')
			{
				document.getElementById('zoom').innerHTML = "<center>Verificando cadastros anteriores, por favor aguarde<br><img src='img/ajax-loader.gif'alt='Carregando...'></center>";
			}
			else if(page != 'definir.asp')
			{
				document.getElementById("inner").innerHTML = "<center><img src='img/ajax-loader.gif'></center>";
			}
		
		}
		
		if(ajax.readyState == 4 && ajax.status == 200)
		{
			retorno_ajax_lista(ajax.responseText);
		}
	}
	
	function retorno_ajax_lista(response)
	{		
		
		if (response == "404") 
		{
			location.href= 'index.asp';
		}
		else if (response == "precisa logar ou sessão expirou")
		{
			location.href="cadastro.asp?q=expirou";
		}
		else if (response == "erro" || response=="existe" && page=='testalogin.asp')
		{
			$('#zoom').fadeOut();
			document.getElementById("info_valida_login").style.color='red';
			document.getElementById("info_valida_login").innerHTML='Nome de usuário já ocupado';
			if (document.getElementById("imglogin") != null)
			{
				document.getElementById("imglogin").src='img/invalido.jpg';
				document.getElementById("imglogin").alt='invalido';
			}
		}
		else if (response=="ok" && page=='testalogin.asp')
		{
			$('#zoom').fadeOut();
			document.getElementById("info_valida_login").style.color='green';
			document.getElementById("info_valida_login").innerHTML='Nome de usuário disponível';
			if (document.getElementById("imglogin") != null)
			{
				document.getElementById("imglogin").src='img/valido.jpg';
				document.getElementById("imglogin").alt='valido';
			}
		}
		else if (response == "sem foto para definir")
		{
			window.alert("Essa imagem não tem uma foto Para definir sua categoria, escolha uma foto antes.");
		}
		else if(response == "foto enviada")
		{
			window.alert("Foto definida com sucesso.");
		}
		else if (response == "sem cliente")
		{
			document.getElementById("cliente").innerHTML = "Bem vindo, Visitante"
			window.alert('Este usuário não existe no sistema, ou a senha está incorreta.');
			document.frmlogincliente.txtlogincliente.value='';
			document.frmlogincliente.txtsenhacliente.value='';
			document.frmlogincliente.txtlogincliente.focus();
		}
		else if (response == "problema no sistema")
		{
			window.alert('Erro de sistema. Por favor, contate o suporte.');
		}
		else if (response=='Tentativa de invasao')
		{
			if (page=='testalogin.asp' || page=='validaemail.asp')
			{
				window.alert('Caracteres inválidos digitados em um dos campos. Não use Aspas simples.');
				document.getElementById("zoom").style.display='none';
			}
			else
			{
				document.getElementById("cliente").innerHTML = "Bem vindo, Visitante"
				window.alert('Caracteres inválidos digitados em um dos campos. Não use Aspas simples ou expressões, como: -- drop, ou --drop');
				document.frmlogincliente.txtlogincliente.value='';
				document.frmlogincliente.txtsenhacliente.value='';
				document.frmlogincliente.txtlogincliente.focus();
			}
		}
		else if (page=='logincliente.asp' && name=='aa')
		{
			window.location.reload();
		}
		else if (page=='logoutcliente.asp' && name =='aa')
		{
			window.location.reload();
		}
		else if(page == 'validacep.asp')
			{
				document.frmcadastro.txtendereco.value = response.substr(response.indexOf("endereco:") + 9,response.indexOf(";endereco")-9);
				document.frmcadastro.txtbairro.value = response.substr(response.indexOf("bairro:") + 7,response.indexOf(";bairro") - response.indexOf("bairro:") - 7);
				document.frmcadastro.txtcidade.value = response.substr(response.indexOf("cidade:") + 7,response.indexOf(";cidade") - response.indexOf("cidade:") - 7);
			}
		else if (page=='actcrud.asp')
			{
				if (tabela == 'tabprodutos')
				{
					document.getElementById("delproduto").innerHTML	= response;
				}
				else if (tabela == 'tabcategoria')
				{
					document.getElementById("delcategoria").innerHTML = response;
				}
				else if(tabela == 'moderador')
				{
					document.getElementById("delmoderador").innerHTML = response;
				}
				else if(tabela == 'tabvendedor')
				{
					document.getElementById("delvendedor").innerHTML = response;
				}
			}
		else
		{
			if (page == 'produto.asp')
			{
				document.getElementById("zoom").innerHTML = response;
			}
			else if (page=='filtro.asp')
			{
				document.getElementById('foto').innerHTML = response;
				gerencialinks();
			}
			else if (page=='logincliente.asp' || page=='logoutcliente.asp')
				{
					document.getElementById("cliente").innerHTML = response;
					if(page=='logincliente.asp')
					{
						document.frmlogincliente.innerHTML = 'Logado. <a href="javascript:logout();">Sair</a>';
					}
					else
					{
						document.frmlogincliente.innerHTML = '<ul><li><span>Nome de usuário(login):</span><input type="text" name="txtlogincliente"></li><li><li><span>Senha:[<a href="recdados.asp" title="Recuperação de dados">Não consigo acessar</a>]</span><input type="password" name="txtsenhacliente" onkeypress="sendenter(event,this.form)" maxlength="20" /></li><li><a style="color:blue;" id="logar" onclick="login();">Entrar</a></li></ul>';
					}
				}
			else if (page=='edit.asp')
			{
					document.getElementById("edtcadastros").innerHTML = response;
			}
			else if (page=='validaemail.asp')
			{
				if(response == 'nao existe')
				{
					try
					{
						$("#zoom").fadeOut(400);
					}
					catch(e)
					{
						document.getElementById("zoom").style.display='none';
					}

					mostraForm();
				}
				else if (response == "nao ativado")
				{
					document.frmcadastro.action='http://pop.luxiluminacao.com.br/actcadastra.asp?ex=no-val';
					document.frmcadastro.submit();
				}
				else if (response =="existe no site" || response == "existe")
				{
					location.href="warn.asp?q=jacad";
				}
			}
			else if(page!='definir.asp')
			{
				document.getElementById("imagens").innerHTML = response;
				gerencialinks();
			}
			
		}
	}
	
	function voltar(ancora)
{	
	document.getElementById("zoom").innerHTML = "";
	try
	{
		$("#img_zoom").fadeOut(400);
		$("#zoom").fadeOut(400);
	}
	catch(e)
	{	
		document.getElementById('zoom').style.display='none';
	}
	location.href='#' + ancora;
	
}

function login()
{
var login = document.frmlogincliente.txtlogincliente;
var senha = document.frmlogincliente.txtsenhacliente;
var pagemark = 'n';
	if (login.value=='' || senha.value=='')
	{
		window.alert("Preencha os campos Login e Senha corretamente");
		login.value='';
		senha.value='';
		login.focus();
	}
	else
	{
		if (document.getElementById('pagemark') != null && document.getElementById('pagemark').value== 'aa')
		{
			pagemark = document.getElementById('pagemark').value;
			requisicao_ajax_lista('logincliente.asp',login.value,senha.value,pagemark);
		}
		else
		{
			requisicao_ajax_lista('logincliente.asp',login.value,senha.value,pagemark);
		}
	}
}

function logout()
{
var pagemark = 'n';
	if (document.getElementById('pagemark') != null && document.getElementById('pagemark').value== 'aa')
	{
		pagemark = document.getElementById('pagemark').value;
		requisicao_ajax_lista('logoutcliente.asp',null,null,pagemark);
	}
	else
	{
		requisicao_ajax_lista('logoutcliente.asp',null,null,pagemark);
	}

}

function sendenter(event,form)
{
	var e = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	window.alert(form.name);
	if (e==13)
	{
		if(form.name=='frmlogincliente')
		{
			login();
		}
		else if (form.name =='frmcadastro')
		{
			validaemail(form.txtemail.value);
		}
	}
}

function rForm()
{
document.frmcadastro.txtemail.disabled=0;
document.frmcadastro.reset();
}

function validaemail(email)
{
	var arr = email.indexOf("@");
	var arr2 = email.indexOf("@",arr + 1);
	var dot = email.indexOf(".");
	var tama = parseInt(email.length);
	if (email.length < 6 || arr == -1 || arr2 != -1 || arr == tama - 1 || dot == -1 || dot == tama - 1 )
	{
		window.alert('Digite um e-mail válido');
	}
	else
	{
		try
		{
			$("#zoom").fadeIn(1);
		}
		catch(e)
		{
			document.getElementById("zoom").style.display='block';
		}
		requisicao_ajax_lista('validaemail.asp',email,'s');
	}
}

function mostraForm()
{
try
{
	for (var i=0;i< $("#cadastro li").length;i++)
		{
			if($("ul#cadastro li")[i].id != 'cpf' && $("ul#cadastro li")[i].className != 'form_hidden' && $("ul#cadastro li")[i].id != 'nome' )
			{
				$("ul#cadastro li")[i].style.display='block';
			}
		}
	document.getElementById("validaemail").href='javascript:undo();';
	document.getElementById("validaemail").innerHTML = 'Desfazer';
	document.frmcadastro.txtemail.disabled=true;
	document.frmcadastro.btnsubmit.disabled=false;
	document.getElementsByName("btnsubmit")[0].style.display='block';
	document.getElementsByTagName("h4")[0].innerHTML = "Preencha os campos abaixo para finalizar o seu cadastro"
	turnNull();
}

catch(ie5)
{
	window.alert("Seu navegador aparenta ser o Internet explorer 5.5 ou inferior. Esse navegador é muito antigo e não suporta algumas funções para efetuar o cadastro. Atualize-o no link no topo do site para prosseguir. Obrigado");
	return false;
}

}

function turnTrue()
{
	document.getElementById("info_valida_cpf").style.color='green';
	document.getElementById("info_valida_cpf").innerHTML='Válido';
	document.getElementById("imgcpf").src='img/valido.jpg';
	document.getElementById("imgcpf").alt="cpf válido";
}

function turnFalse()
{
	document.getElementById("info_valida_cpf").style.color='red';
	document.getElementById("info_valida_cpf").innerHTML='Inválido';
	document.getElementById("imgcpf").src='img/invalido.jpg';
	document.getElementById("imgcpf").alt="cpf inválido";
}
function turnNull()
{			document.getElementById("info_valida_cpf").style.color='gray';
			document.getElementById("imgcpf").src="img/valida_cpf_null.jpg";
			document.getElementById("imgcpf").alt="Digite o documento";
			document.getElementById("info_valida_cpf").innerHTML='';
}

function undo()
{
var	a = confirm('Para apagar todos os dados e refazer o cadastro clique em Ok. Caso queira apenas alterar o e-mail clique em cancelar.');
	if (a==true)
	{
		document.getElementById('info_valida_login').style.color='gray';
		document.getElementById('info_valida_login').innerHTML = 'Digite um nome de usuário';
		document.getElementById("imglogin").src='img/valida_cpf_null.jpg';
		document.frmcadastro.reset();
	}
	for (var i=0;i< $("#cadastro li").length;i++)
	{
		if( $("#cadastro li")[i].id != 'email')
		{
			$("#cadastro li")[i].style.display='none';
		}
		
	}
document.frmcadastro.txtemail.value='';
document.frmcadastro.txtemail.disabled=false;
document.frmcadastro.txtemail.focus();
document.getElementById("validaemail").href='javascript:validaemail(document.frmcadastro.txtemail.value);';
document.getElementById("validaemail").innerHTML = "Prosseguir";
document.frmcadastro.btnsubmit.style.display='none';
document.frmcadastro.btnsubmit.disabled=true;
}

function checkDoc()
	{
		var retorno;
		if (document.frmcadastro.rdbdoc[0].checked==true)
		{
			if (document.frmcadastro.txtcpf.value.length > 11)
			{
				document.frmcadastro.txtcpf.value = document.frmcadastro.txtcpf.value.substr(0,11);
			}
			document.frmcadastro.txtcpf.maxLength='11';
			document.frmcadastro.txtcpf.onkeyup=function(){validatecla('11');};
			document.getElementById("nome").style.display='block';
			if (document.frmcadastro.txtcpf.value != '')
			{
				retorno = validacpf();
				if (retorno == false)
				{
						turnFalse();
				}
				else
				{
					turnTrue();
				}
			}
			
			document.getElementById("cpf").getElementsByTagName("span")[0].innerHTML = 'Digite o CPF: ';
			document.getElementById("cpf").style.display='block';
			document.getElementById("sprg").innerHTML = "RG: "
			$(".form_hidden").css({"display":"block"});
		}
		else if(document.frmcadastro.rdbdoc[1].checked==true)
		{
			document.frmcadastro.txtcpf.maxLength='14';
			document.frmcadastro.txtcpf.onkeyup=function(){validatecla('14');};
			document.getElementById("nome").getElementsByTagName("span")[0].innerHTML = 'Razão Social: ';
			document.getElementById("nome").style.display='block';
			if(document.frmcadastro.txtcpf.value != '')
			{
				retorno = validacnpj();
				if (retorno == false)
				{
						turnFalse();
				}
				else
				{
					turnTrue();
				}
			}
			document.getElementById("cpf").getElementsByTagName("span")[0].innerHTML = 'Digite o CNPJ: '
			document.getElementById("cpf").style.display='block';
			document.getElementById("sprg").innerHTML = 'I.E:';
			$(".form_hidden").css({"display":"block"});
		}
	}
	
function validacnpj()
{		
						
	try
	{
		var cnpj = document.frmcadastro.txtcpf.value;
		
		if(cnpj == "00000000000000" || cnpj == "11111111111111" || cnpj == "22222222222222" || cnpj == "33333333333333" || cnpj == "44444444444444" || cnpj == "55555555555555" || cnpj == "66666666666666" || cnpj == "77777777777777" || cnpj == "88888888888888" || cnpj == "99999999999999")
			{
				return false;
			}
		
		var cnpj2 = cnpj.substr(0,12);
		a_vdigito = new Array(2);
		var a_verificador = Array(5,4,3,2,9,8,7,6,5,4,3,2);
		for (var i=0;i<2;i++)
		{	
			var soma = 0;
			for (var i2=0;i2<a_verificador.length;i2++)
			{
				soma = parseInt(cnpj2.substr(i2,1)) * a_verificador[i2] + soma; 
			}
			if (soma%11 < 2)
			{
				a_vdigito[i] = 0;
				cnpj2 = cnpj2 + 0;
			}
			else
			{
				a_vdigito[i] = 11 - (soma%11);
				cnpj2 = cnpj2 + (11 - (soma%11));
			}
			a_verificador = Array(6,5,4,3,2,9,8,7,6,5,4,3,2);
		}
		if (cnpj == cnpj2)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	catch(user_for_mula)
	{
		return false;
	}
}

function validaCep(e)
{
	if(e.value.indexOf("-") != -1)
	{
		window.alert('Digite apenas números, no CEP.');
	}
	else
	{
		if( e.value != "")
		{
			requisicao_ajax_lista('validacep.asp',e.value);
		}
	}
}

function testalogin(input)
{
var valor = input.value;
	if (valor.length > 0)
	{
		if (achaespaco(valor) ==true)
		{
			document.getElementById("imglogin").src='img/invalido.jpg';
			document.getElementById("imglogin").alt='invalido';
			document.getElementById("info_valida_login").innerHTML='Não use espaços';
		}
		else
		{
			if (valor.length > 3 )
			{
				try 
				{
					$("#zoom").fadeIn(1);
				}
				catch(e)
				{
					document.getElementById('zoom').style.display='block';       //show('slow');
				}
				requisicao_ajax_lista('testalogin.asp',valor);
			}
			else
			{
				window.alert('Seu nome de usuário Deve Ter mais do que 3 digitos');
				input.focus();
				input.style.border='1px solid red';
			}
	}
}
}

function achaespaco(string)
{
var retorno = false;
	if (string.indexOf(' ') != -1)
	{
		retorno=true;
	}
	return retorno;
}

function turn()
{
	document.getElementById("info_valida_login").style.color='gray';
	document.getElementById("info_valida_login").innerHTML='Digite um nome de usuário';
	if (document.getElementById("imglogin") != null)
	{
		document.getElementById("imglogin").src='img/valida_cpf_null.jpg';
		document.getElementById("imglogin").alt='none';
	}
}

function validacpf()
{
var cpf = document.frmcadastro.txtcpf.value;
	var i2=10;
	var soma = 0;
	var d1;
	var d2;
			for (var i=0;i<9;i++)
			{
				soma = soma + cpf.substr(i,1) * i2;
				i2 = i2-1;
			}
			if (soma % 11 < 2 )
			{
				d1 = "0";
			}
			else
			{
				d1 = "" + (11 - (soma % 11));
			}
			soma = 0;
			i=0;
			i2=11;
			for (i=0;i<10;i++)
			{
				soma = soma + cpf.substr(i,1) * i2;
				i2 = i2-1;
			}

			if (soma % 11 < 2 )
			{
				d2 = "0";
			}
			else
			{
				d2 = "" + (11 - (soma % 11));
			}
			if(cpf.substr(0,9) + d1 + d2 != cpf)
			{
				return false;
			}
			else if(cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")
			{
				return false;
			}
			else
			{
				return true;
			}
}

function validatecla(maxlength)
{
var retorno;
	if (document.frmcadastro.rdbdoc[0].checked==false && document.frmcadastro.rdbdoc[1].checked ==false && document.frmcadastro.txtcpf.value!='')
	{
		turnFalse();
	}
	else
	{
		if (document.frmcadastro.txtcpf.value.length < maxlength)
		{
			turnNull();
		}
		if (document.frmcadastro.txtcpf.value.length == parseInt(maxlength))
		{
			if(parseInt(maxlength) == 11)
			{
				retorno = validacpf();
				if (retorno == true)
				{
					turnTrue();
				}
				else if(retorno == false)
				{
					turnFalse();
				}
			}
			else if (parseInt(maxlength) == 14)
			{
				retorno = validacnpj();
				if(retorno == true)
				{
					turnTrue();
				}
				else if (retorno == false)
				{
					turnFalse();
				}
			}
		}
	}
}

function validaform(formulario)
{
var retorno;
	if (document.getElementById("cadastro").getElementsByTagName("li")[2].style.display != "block")
	{
		return false;
	}
	for (i=0;i<formulario.length;i++)
	{
		if(formulario[i].name.indexOf("rdb") == -1 && formulario[i].name != "txtcpf")
		{
			if (formulario[i].className == "cinput" || formulario[i].className == "cadastro cinput")
			{
				if (formulario[i].value == "")
				{
					if(formulario[i].name == "txtcpf" || formulario[i].name == "txtrg")
					{
						window.alert('Selecione um tipo de pessoa e preencha os campos que aparecerão em seguida');
					}
					else
					{
						window.alert('Há Campos em branco. Preencha-os corretamente');
					}
						try
						{
							formulario[i].focus();
							formulario[i].style.border='1px solid red';
							return false;
						}
						catch(hidden)
						{
							return false;
						}
						
					
				}
				
				if(formulario[i].name == "txtendereco")
				{
				
					if(formulario[i].value.indexOf("0") == -1 && formulario[i].value.indexOf("1") == -1 && formulario[i].value.indexOf("2") == -1 && formulario[i].value.indexOf("3") == -1 && formulario[i].value.indexOf("4") == -1 && formulario[i].value.indexOf("5") == -1 && formulario[i].value.indexOf("6") == -1 && formulario[i].value.indexOf("7") == -1 && formulario[i].value.indexOf("8") == -1 && formulario[i].value.indexOf("9") == -1)
					{
						window.alert('Digite o número de sua residência');
						formulario[i].focus();
						formulario[i].style.border='1px solid red';
						return false;
					}
					
				}
				
				if (formulario[i].name == "txtemail")
				{
					if(formulario[i].value.length < 4 || formulario[i].value.indexOf("@") == -1 || formulario[i].value.indexOf(".")== -1 )
					{	
						window.alert('Digite um e-mail válido');
						if (formulario[i].disabled == false)
						{
							document.frmcadastro.txtemail.focus();
							document.frmcadastro.style.border='1px solid red';
						}
						return false;
					}
				}
				
				if (formulario[i].name == "txtsenha")
				{
					if(formulario[i].value != document.frmcadastro.txtconfirmasenha.value)
					{
						window.alert('As Senhas digitadas não coincidem.');
						document.frmcadastro.txtconfirmasenha.focus();
						document.frmcadastro.txtconfirmasenha.style.border='1px solid red';
						return false;
					}
				}
				
				if (formulario[i].name == "txtlogin")
				{
					if (achaespaco(formulario[i].value) == true)
					{
						window.alert('Não use espaço no nome de usuário');
						document.frmcadastro.txtlogin.focus();
						document.frmcadastro.txtlogin.style.border='1px solid red';
						return false;
					}
				}
				
				if (formulario[i].name == "txttelefone")
				{
					if (formulario[i].value.substr(0,1) != "2" && formulario[i].value.substr(0,1) != "3" && formulario[i].value.substr(0,1) != "4" && formulario[i].value.substr(0,1) != "5")
					{
						window.alert('Por favor, digite um número de telefone fixo.');
						document.frmcadastro.txttelefone.focus();
						document.frmcadastro.txttelefone.style.border='1px solid red';
						return false;
					}
				}
				
				if (formulario[i].name == "txtcep")
				{
					if (formulario[i].value.length < 8)
					{
						window.alert('Digite um CEP Válido');
						document.frmcadastro.txtcep.focus();
						document.frmcadastro.txtcep.style.border='1px solid red';
						return false;
					}
				}
				
			}
			else if (formulario[i].className == "cselect" || formulario[i].className == "cadastro cselect")
			{
				if (formulario[i].selectedIndex == 0)
				{
					if (formulario[i].name == "ssexo")
					{
						window.alert('Selecione uma Opção válida no campo sexo.');
					}
					else
					{
						window.alert('Selecione uma opção no campo Estado');
					}
					return false;
				}
			}
		}
	}
	if (document.frmcadastro.txtnome.value.indexOf(" ") == -1)
	{
		window.alert('Favor Digitar Nome completo.');
		document.frmcadastro.txtnome.focus();
		document.frmcadastro.txtnome.style.border='1px solid red';
		return false;
	}

	if (document.frmcadastro.rdbdoc[0].checked == false && document.frmcadastro.rdbdoc[1].checked == false)
	{
		window.alert('Por favor, escolha um documento (CPF ou CNPJ) e preencha o campo que aparecerá com o número');
		return false;
	}
	if(document.getElementById("imglogin").alt == 'invalido')
	{
		window.alert('Esse Nome de usuário já existe. Tente outro e pressione o botão validar.Caso acenda a luz verde significa que esse nome de usuário está disponível');
		document.frmcadastro.txtlogin.focus();
		document.frmcadastro.txtlogin.style.border='1px solid red';
		return false;
	}
	if (document.getElementById("imglogin").alt == 'none')
	{
		window.alert('Você não clicou no botão Validar');
		return false;
	}
	
	if(document.getElementById("imgcpf").alt != 'cpf válido')
	{
		window.alert('Digite um número de CPF/CNPJ válido');
		document.frmcadastro.txtcpf.focus();
		document.frmcadastro.txtcpf.style.border='1px solid red';
		return false;
	}
	document.frmcadastro.txtemail.disabled=0;
	return true;
}
function sendenter(event,form)
{
var e = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (e==13)
	{
		if(form.name=='frmlogincliente')
		{
			login();
		}
		else if (form.name == 'frmcadastro')
		{
			validaemail(document.frmcadastro.txtemail.value);
		}
	}
}
function turnBorderNull(i)
{
	if (i.name == "txtconfirmasenha" || i.name == "txtsenha")
	{
		i.style.border = '1px solid #7f9db9';
		document.getElementsByName("txtconfirmasenha")[0].style.border='1px solid #7f9db9';
	}
	else
	{
		i.style.border='1px solid #7F9DB9';
	}
}

function bigImg(post,n)
{
	document.getElementById("zoom").innerHTML = "<center><img src='img/ajax-loader.gif'></center>"
	$("#zoom").fadeIn();
	if(post == 'website')
	{
		document.getElementById("zoom").innerHTML = '<center> <img style="margin-top:80px;"src="img/eventos/website/wide/site' + n + '.jpg" alt="Foto Ampliada"><br>Foto Ampliada, Novo Website Lux Iluminação </center><br><a style="color:blue;cursor:pointer;padding-left:10px;" onclick="closeImg()">Clique aqui para fechar</a>';
	}
	else
	{
		if (n < 10)
		{
			n = "0" + n;
		}
		document.getElementById("zoom").innerHTML = '<center> <img style="margin-top:80px;"src="img/eventos/expo/wide/expo' + n + '.jpg" alt="Foto Ampliada"><br>Foto Ampliada, Aniversário da Lux Iluminação + Expo Music 2009</center><br><a style="color:blue;cursor:pointer;padding-left:10px;" onclick="closeImg()">Clique aqui para fechar</a>';
	}
}
function closeImg()
{
	document.getElementById("zoom").innerHTML = "";
	try
	{
		$("#zoom").fadeOut();
	}
	catch(ie5)
	{
		document.getElementById("zoom").style.display='none';
	}
}

function validaFormRecData(f)
{
	var retorno=false;
	for(var i=0;i<f.length;i++)
	{
		if(f[i].value != '' && f[i].id != 'btnsenddata')
		{
			retorno = true;
		}
	}
	if (retorno == false)
	{
		window.alert("Preencha pelo menos um dos campos");
		f[0].focus();
	}
	return retorno;
}

function validaForm_active(fr)
{
var ret=true;
var msg_output = "";
	for(var i=0;i<fr.length;i++)
	{
		if (fr[i].name != undefined && fr[i].name != '')
		{
			if(fr[i].value.length <= 2)
			{
				ret=false;
				msg_output = "Preencha todos os campos corretamente. Eles têm que conter mais de 2 dígitos";
				markField(fr[i],'red');
				break;
			}
			
			if(fr[i].name == 'txtsenha')
			{
				if(fr[i].value != fr[i+1].value)
				{
					msg_output = 'As senhas digitadas não coincidem';
					ret=false;
					break;
				}
			}
		}
		if(document.getElementById('info_valida_login').style.color != 'green')
		{
			msg_output = "Preencha corretamente o campo de Nome de Usuário(login) e clique no botão Validar";
			ret=false;
			break;
		}
	}
	if (msg_output != "")
	{
		window.alert(msg_output);
	}
	return ret;
}

function markField(field,color,qtde)
{
	if (qtde == "" || qtde == undefined || qtde == null)
	{
		qtde = 0;
	}
	if(color == 'green')
	{
		if (field.value.length <= qtde)
		{
			color = 'red';
		}
	}
	field.style.border = '1px solid ' + color;
}