// VOLTAR PÁGINAfunction voltar(){	history.go(-1);}// IMPRIMIR PÁGINAfunction imprimirPagina(){	window.print();}function abrirJanela(url,nome,parametros){ window.open(url,nome,parametros); } /**** ABRIR POPUP *****/function popupImagem(pasta, id){	var link = raiz+'/foto/'+pasta+'/'+id+'/';	var janela = 'popupImagem';	var params = 'resizable=no, scrollbars=no, width=550, height=350';	abrirJanela(link, janela, params);}function mostraResposta(id){	if(document.getElementById('resposta_'+id).style.display == '')		document.getElementById('resposta_'+id).style.display = 'none';	else		document.getElementById('resposta_'+id).style.display = '';}function validaLogin(){	var login = document.getElementById('login[email]').value;	var senha = document.getElementById('login[senha]').value;		if(login == '' || senha == ''){		alert("Informe seu e-mail e senha para continuar");	} else {		$.post(raiz+"/funcoes/cesta.php?funcao=validaLogin",			{_login: login, _senha: senha},			function(data) {				if(data == 1)					redir(raiz+"/pagamento/");				else					alert("E-mail ou Senha inválidos, tente novamente!");			}		)	}}function validaLoginFlash(conta, agencia){	if(conta == '' || agencia == ''){		alert("Informe sua Conta e Agência para continuar");	} else {		$.post(raiz+"/funcoes/geral.php?funcao=validaLogin",			{_conta: conta, _agencia: agencia},			function(data) {				if(data == 1)					redir(location);				else					alert("Conta ou Agência inválida, tente novamente!");			}		)	}}function sairLoginFlash(){	$.post(raiz+"/funcoes/geral.php?funcao=sairLogin",		{},		function(data) {			if(data == 1)				redir(location);		}	)}function cadastrarDependente(){	var nome = document.getElementById('cad[nome]').value;	var parentesco = document.getElementById('cad[parentesco]').value;	var nascimento = document.getElementById('cad[nascimento]').value;	var sexo = document.getElementById('cad[sexo]').value;	var estado_civil = document.getElementById('cad[estado_civil]').value;	var id_dependente = document.getElementById('cad[id_dependente]').value;		if(nome == '' || parentesco == '' || nascimento == '' || sexo == '' || estado_civil == ''){		alert("Preencha os campos obrigatórios!");	} else {		$.post(raiz+"/funcoes/geral.php?funcao=cadastrarDependente",			{nome:nome, parentesco:parentesco, nascimento:nascimento, sexo:sexo, estado_civil:estado_civil, id_dependente:id_dependente},			function(data) {				if(data == 1)					redir(location);				else					alert("Erro ao cadastrar dependente");			}		)	}}function editarDependente(id_dependente){	var nome = document.getElementById('cad[nome]').value;	var parentesco = document.getElementById('cad[parentesco]').value;	var nascimento = document.getElementById('cad[nascimento]').value;	var sexo = document.getElementById('cad[sexo]').value;	var estado_civil = document.getElementById('cad[estado_civil]').value;		if(nome == '' || parentesco == '' || parentesco == '' || nascimento == '' || sexo == '' || estado_civil == ''){		alert("Preencha os campos obrigatórios!");	} else {		$.post(raiz+"/funcoes/geral.php?funcao=editarDependente",			{nome: nome, parentesco: parentesco, nascimento: nascimento, sexo: sexo, estado_civil: estado_civil, id_dependente:id_dependente},			function(data) {				if(data == 1)					redir(location);				else					alert("Erro ao editar dependente");			}		)	}}function carregarDependente(id_dependente){		$.post(raiz+"/funcoes/geral.php?funcao=carregarDependente",			{id_dependente: id_dependente},			function(data) {				if(data == 1)					redir(location);				else					alert("Erro ao editar dependente");			}		)}function excluirDependente(id_dependente){	$.post(raiz+"/funcoes/geral.php?funcao=excluirDependente",		{id_dependente:id_dependente},		function(data) {			if(data == 1)				redir(location);			else				alert("Erro ao excluir dependente");		}	)}function gerarDebito(){	var passagens = document.getElementById('cad[passagens]').value;	var valor_total = document.getElementById('cad[valor_total]').value;	var parcelas = document.getElementById('cad[parcelas]').value;	var cidade = document.getElementById('cad[cidade]').value;	var data = document.getElementById('cad[data]').value;		if(parcelas > 5 || parcelas < 1){		alert("Informe entre 1 ou 5 parcelas!");	} else 	{		if(passagens == '' || valor_total == '' || parcelas == '' || cidade == '' || data == ''){			alert("Preencha os campos obrigatórios!");		} else {			$.post(raiz+"/funcoes/geral.php?funcao=gerarDebito",				{passagens:passagens, valor_total:valor_total, parcelas:parcelas, cidade:cidade, data:data},				function(data) {					if(data == 1){						abrirJanela(raiz+'/aceite.php', 'Aceite', 'width = 640, height= 600');												//window.open(raiz+'/aceite.php', 'janela', 'width = 640, height= 600');						/*document.getElementById('cad[passagens]').value = '';						document.getElementById('cad[valor_total]').value = '';						document.getElementById('cad[parcelas]').value = '';						document.getElementById('cad[cidade]').value = '';						document.getElementById('cad[data]').value = '';*/					} else						alert("Erro ao gerar Aceite de Débito");				}			)		}	}}function enviarContatoSite(){			var nome = document.getElementById('cad[nome]').value;	var telefone = document.getElementById('cad[telefone]').value;	var email = document.getElementById('cad[email]').value;	var msg = document.getElementById('cad[msg]').value;		if(nome == '' || email == '' || msg == ''){		alert("Preencha os campos obrigatórios para continuar asdfasd!");	} else {		$.post(raiz+"/funcoes/geral.php?funcao=enviarContatoSite",			{_nome: nome,			 _telefone: telefone,			 _email: email,			 _msg: msg},			function(data) {				if(data == 1)					alert("Erro ao enviar a mensagem, tente novamente!");				else					alert("Mensagem enviada com sucesso!");			}		)	}}// INDICAR PÁGINA POPUPfunction indicarPagina(){	window.open(raiz+'/indicar/', 'indicar', 'resizable=no, scrollbars=no, width=400, height=196');}function indicarPaginaEnviar(){	submitForm('formIndicar', 'retornoIndicar');}function enviarContato(){	submitForm('formContato', 'retornoIndicar');}// ADICIONA OPTION NOS SELECTSfunction addCombo(combo, value, texto){	var novo = document.createElement("option");	novo.value = value;	novo.text = texto;	combo.options.add(novo);}// REDIRECIONAR USUÁRIOfunction redir(url){	window.location = url;}function mostrarArquivo(linha){	var valor = $('linhaOculta'+linha).style.display;	if(valor == 'none')		$('linhaOculta'+linha).style.display = '';	else		$('linhaOculta'+linha).style.display = 'none';}// ADICIONAR SITE AOS FAVORITOSfunction addFav(){	var url   = raiz;	var title = "Produtos Vida Orgânica";	if (window.sidebar) window.sidebar.addPanel(title, url,"");	else if(window.opera && window.print){		var mbm = document.createElement('a');		mbm.setAttribute('rel','sidebar');		mbm.setAttribute('href',url);		mbm.setAttribute('title',title);		mbm.click();	}else if(document.all)		window.external.AddFavorite(url, title);}function popupCidade(tipo, id, categoria){	//var status = (aparecer) ? '' : 'none';		if(id == '0' && tipo == '1'){				var num = Math.floor(Math.random()*15);		var so = new SWFObject(raiz+"/swf/cidades.swf?"+num, "popupCidade", "100%", "100%", "8.0.0", "");		so.addVariable("id", id);		so.addVariable("categoria", categoria);		so.addVariable("raiz", raiz);		so.addParam("wmode", "transparent");		so.write("popupCidade");	} else {		document.getElementById('popupCidade').innerHTML = '';		if(categoria != '0')			redir(raiz+'/produtos-organicos/'+categoria+'/');		else			redir(raiz+'/produtos/');	}	document.getElementById('popupCidade').style.display = '';}// POPUP QUE EXIBE A IMAGEM GRANDEfunction popupCidadeH(tipo, id, categoria){	$.post(raiz+"/funcoes/cesta.php?funcao=popupCidadeH",		{_tipo: tipo,		 _id: id,		 _categoria: categoria},		function(data) {			document.getElementById('popupCidadeHtml').innerHTML = data;		}	)}function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, 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;    	var whichCode = (window.addEventListener) ? e.which : e.keyCode;    // 13=enter, 8=backspace as demais retornam 0(zero)    // whichCode==0 faz com que seja possivel usar todas as teclas como delete, setas, etc        if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8))    	return true;    key = String.fromCharCode(whichCode); // Valor para o código da Chave      if (strCheck.indexOf(key) == -1)     	return false; // Chave inválida    len = objTextBox.value.length;    for(i = 0; i < len; i++)        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal))         	break;    aux = '';    for(; i < len; i++)        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1)         	aux += objTextBox.value.charAt(i);    aux += key;    len = aux.length;    if (len == 0)     	objTextBox.value = '';    if (len == 1)     	objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;    if (len == 2)     	objTextBox.value = '0'+ SeparadorDecimal + aux;    if (len > 2) {        aux2 = '';        for (j = 0, i = len - 3; i >= 0; i--) {            if (j == 3) {                aux2 += SeparadorMilesimo;                j = 0;            }            aux2 += aux.charAt(i);            j++;        }        objTextBox.value = '';        len2 = aux2.length;        for (i = len2 - 1; i >= 0; i--)        	objTextBox.value += aux2.charAt(i);        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);    }    return false;}